-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[UI Framework] [K7] Add keyboard navigation to KuiContextMenu. #14108
[UI Framework] [K7] Add keyboard navigation to KuiContextMenu. #14108
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is gold! Thanks a lot for that. Except the two points you mentioned yourself, that should still be done (especially I like the Escape closing), I just found one bug (pressing left in upmost panel), and two suggestions for using state updater functions.
Since I am in vacation next week, I already give this a LGTM as long as those are fixed.
const nextFocusedMenuItemIndex = this.state.focusedMenuItemIndex - 1; | ||
|
||
this.setState({ | ||
focusedMenuItemIndex: nextFocusedMenuItemIndex < 0 ? this.menuItems.length - 1 : nextFocusedMenuItemIndex, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const nextFocusedMenuItemIndex = this.state.focusedMenuItemIndex + 1; | ||
|
||
this.setState({ | ||
focusedMenuItemIndex: nextFocusedMenuItemIndex > this.menuItems.length - 1 ? 0 : nextFocusedMenuItemIndex, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here: should rather use updater function
}); | ||
}, 250); | ||
} | ||
|
||
showPreviousPanel = () => { | ||
const previousPanelId = this.props.idToPreviousPanelIdMap[this.state.currentPanelId]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is actually a bug, that you can press Left in the topmost menu and will receive an empty menu. I assume a check here would be the fix.
Btw I've noticed something else, which may or may not be a bug in this component. On the ui framework docs page of this component the search in the menu doesn't work. It will immediately take the focus away when clicking into the search. It doesn't seem to happen on other component pages (though I haven't tested all of them). |
180d73e
to
24f0fa7
Compare
…ver and return focus to originating element on close.
Thanks guys! I addressed the bugs and errors you found. |
You can use the up and down keys to navigate through the items in each menu, and the left and right keys to go to the previous and next menus. You can use the escape key to close the enclosing popover.
TODO: