Skip to content

Commit

Permalink
fix(Menu): focused items should scrollintoview when overflowed (patte…
Browse files Browse the repository at this point in the history
…rnfly#9408)

* Rebase postv5 (patternfly#9393)

* chore(deps): bump docs framework (patternfly#9370)

* chore(docs): Updated screenshots (patternfly#9337)

* chore(docs): Updated screenshots

* updated screenshots after logo update

---------

Co-authored-by: Titani <tlabaj@redaht.com>

* chore(release): releasing packages [ci skip]

 - @patternfly/react-docs@6.0.0-prerelease.26

* chore(deps): bump to latest chore version (patternfly#9389)

* chore(deps): bump to latest chore version

* bump to 16

* chore(release): releasing packages [ci skip]

 - @patternfly/react-charts@7.0.0-prerelease.12
 - @patternfly/react-code-editor@5.0.0-prerelease.24
 - @patternfly/react-core@5.0.0-prerelease.24
 - @patternfly/react-docs@6.0.0-prerelease.27
 - @patternfly/react-icons@5.0.0-prerelease.9
 - demo-app-ts@5.0.0-prerelease.22
 - @patternfly/react-styles@5.0.0-prerelease.7
 - @patternfly/react-table@5.0.0-prerelease.24
 - @patternfly/react-tokens@5.0.0-prerelease.9

* fix(fileupload): use default readonly text input instead of plain (patternfly#9387)

* fix(fileupload): use default readonly text input instead of plain

* chore(build): snaps

* fix(CodeEditor): prevent clicks in textarea from opening fileupload (patternfly#9385)

* fix(toolbar): added chip container class to toolbar content (patternfly#9379)

* feat(Menu): added support for tooltips to menu (patternfly#9382)

* fix(whitespace): Update readme to trigger release

* chore(release): releasing packages [ci skip]

 - @patternfly/react-code-editor@5.0.0-prerelease.25
 - @patternfly/react-core@5.0.0-prerelease.25
 - @patternfly/react-docs@6.0.0-prerelease.28
 - demo-app-ts@5.0.0-prerelease.23
 - @patternfly/react-table@5.0.0-prerelease.25

* fix(Toolbar): resolved typeerror on full page demo (patternfly#9355)

* chore(TreeView): converted examples to TS (patternfly#9286)

* fix(ExpandableSection): added ARIA attributes (patternfly#9303)

* fix(ExpandableSection): added ARIA attributes

* Updated failing snapshots due to mismatching generated ID

* chore(Tooltip): updated unit tests (patternfly#9295)

* chore(Tooltip): updated unit tests

* Updated mock and tests

* Updated based on Austin feedback

* Updated integration tests

* Removed unused imports

* Updated remaining tests using Popper mock

* Removed extraenous snapshot test

* Removed test

* Split out onTooltipHidden test

* chore(Card): added tests for new clickable/selectable (patternfly#9262)

* chore(Card): added tests for new clickable/selectable

* Added tests for clickable cards

* Updated card with actions test

* fix(Slider): reverted taborder (patternfly#9293)

* fix(chore): Fix deprecated wizard integration tests (patternfly#9312)

* fix(chore): Fix deprecated wizard integration tests

* updated non deprecated test as well

---------

Co-authored-by: Titani <tlabaj@redaht.com>

---------

Co-authored-by: Titani <tlabaj@redaht.com>
Co-authored-by: patternfly-build <patternfly-build@redhat.com>
Co-authored-by: Michael Coker <35148959+mcoker@users.noreply.github.com>
Co-authored-by: Dallas <dallas.nicol@gmail.com>
Co-authored-by: Dana Gutride <dgutride@gmail.com>
Co-authored-by: Eric Olkowski <70952936+thatblindgeye@users.noreply.github.com>

* fix(Menu): focused items should scrollintoview when overflowed

* fix merge error

* fix merge snap

* change scroll to auto

---------

Co-authored-by: Titani Labaj <39532947+tlabaj@users.noreply.github.com>
Co-authored-by: Titani <tlabaj@redaht.com>
Co-authored-by: patternfly-build <patternfly-build@redhat.com>
Co-authored-by: Michael Coker <35148959+mcoker@users.noreply.github.com>
Co-authored-by: Dallas <dallas.nicol@gmail.com>
Co-authored-by: Dana Gutride <dgutride@gmail.com>
Co-authored-by: Eric Olkowski <70952936+thatblindgeye@users.noreply.github.com>
  • Loading branch information
8 people authored and nicolethoen committed Sep 1, 2023
1 parent 182baa4 commit 354549e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/react-core/src/components/Menu/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,23 @@ const MenuItemBase: React.FunctionComponent<MenuItemProps> = ({
setFlyoutRef(null);
}
};

React.useEffect(() => {
if (isFocused && ref.current) {
const itemEl = ref.current;
const parentListEl = itemEl.parentElement;

if (parentListEl) {
const isAboveTop = itemEl.offsetTop - parentListEl.offsetTop < parentListEl.scrollTop;
const isBelowBottom = itemEl.offsetTop - parentListEl.offsetTop + itemEl.clientHeight;

if (isAboveTop || isBelowBottom) {
itemEl.scrollIntoView({ behavior: 'auto', block: 'nearest' });
}
}
}
}, [isFocused]);

const isSelectMenu = menuRole === 'listbox';

const renderItem = (
Expand Down

0 comments on commit 354549e

Please sign in to comment.