Skip to content
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

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

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Changes from 2 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
6 changes: 3 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,9 @@
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;

Check failure on line 160 in packages/react-core/src/components/Menu/Menu.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected '===' and instead saw '=='

Check failure on line 160 in packages/react-core/src/components/Menu/Menu.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected { after 'if' condition
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 +168,6 @@
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
Loading