Skip to content

fix(Menu): Fix crash in menu referencing invalid array index #10153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/react-core/src/components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,11 @@ class MenuBase extends React.Component<MenuProps, MenuState> {
this.setState({ transitionMoveTarget: null });
} else {
const nextMenu = current.querySelector('#' + this.props.activeMenu) || current || null;
const nextMenuChildren = Array.from(nextMenu.getElementsByTagName('UL')[0].children);

const nextMenuLists = nextMenu.getElementsByTagName('UL');
if (nextMenuLists.length === 0) {
return;
}
const nextMenuChildren = Array.from(nextMenuLists[0].children);
if (!this.state.currentDrilldownMenuId || nextMenu.id !== this.state.currentDrilldownMenuId) {
this.setState({ currentDrilldownMenuId: nextMenu.id });
} else {
Expand All @@ -167,7 +170,6 @@ class MenuBase extends React.Component<MenuProps, MenuState> {
const nextTarget = nextMenuChildren.filter(
(el) => !(el.classList.contains('pf-m-disabled') || el.classList.contains(styles.divider))
)[0].firstChild;

(nextTarget as HTMLElement).focus();
(nextTarget as HTMLElement).tabIndex = 0;
}
Expand Down