-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Keyboarding is inconsistent when interacting with a SearchBox in a menu #20074
Comments
Thanks for filing this issue with us. To set expectations the developers will review this issue once capacity allows. |
@gouttierre Just checking in as this bug has been active for a while. Is this issue still on your radar? |
@gouttierre Can you please suggest workaround for this issue in the meantime? How can I at least programatically focus correct MenuItem? I cannot seem to find componentRef that can be focused. |
This issue has been queued for upcoming investigations. To set expectations the developers will review this issue once capacity allows and all updates will be posted on the issue accordingly. If a work around is found during investigations they will share the implementations with you. |
The focus inside the menu is managed by a In the case of the <DefaultButton
...
menuProps={{
...
focusZoneProps: {
shouldInputLoseFocusOnArrowKey: () => true
}
}}
/> Now Arrow Up and Arrow Down navigation should work as expected as long as the input is empty. But once there is a content inside the input, the navigation is broken again. The reason is fluentui/packages/react/src/components/ContextualMenu/ContextualMenu.base.tsx Lines 395 to 422 in 0ee609e
When there is content inside the input and cursor is not at the end of the text in case of Arrow Down (at the beginning of the text in case of Up Arrow) There is a hacky workaround - add key down handler to the const onKeyDown = React.useCallback((e, ...args) => {
/* Key Up, but we are not at the beginning of the text: stop event propagation to prevent ContextualMenu to focus */
if (e.target.selectionStart > 0 && e.which === KeyCodes.up) {
e.stopPropagation();
}
/* Key Down, but we are not at the end of the text: stop event propagation to prevent ContextualMenu to focus */
if (e.target.selectionStart !== e.target.value.length && e.which === KeyCodes.down) {
e.stopPropagation();
}
}, []); Here is a codesandbox demonstrating the working solution: https://codesandbox.io/s/fui-menu-searchbox-dfbx8q. I will create a PR to apply the same changes to the |
Please provide a reproduction of the bug in a codepen:
https://codepen.io/makopch/pen/rNwbwgp
Open the Menu and use the keyboard to cycle through the items
Actual behavior:
The keyboarding is not consistent. If you down arrow in the search box, focus will go back to the top menuitem of the menu. If you up-arrow, focus will go to the last item in the menu.
Expected behavior:
The searchbox should behave like the other menu items and you should be able to arrow in and out of it without jumping to the top or bottom of the menu.
Priorities and help requested:
Are you willing to submit a PR to fix? (Yes, No)
Requested priority: (Blocking, High, Normal, Low) Normal
Products/sites affected: (if applicable)
The text was updated successfully, but these errors were encountered: