-
-
Notifications
You must be signed in to change notification settings - Fork 319
[menu] Fix closeParentOnEsc default value
#2493
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
Conversation
commit: |
Bundle size report
|
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| returnFocus={finalFocus || returnFocus} | ||
| returnFocus={finalTriggerElement || returnFocus} |
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 prevents returnFocus from ever being passed, no?
It seems like finalTriggerElement needs to be part of the if branches above when calculating returnFocus
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.
Included in this commit.
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.
Seems good now - also tested Menubar and the return focus issue this branch was addressing is still not present
| const { closeParentOnEsc = false } = props; | ||
|
|
||
| return ( | ||
| <MenuSubmenuRootContext.Provider value> | ||
| <MenuRoot {...props} /> | ||
| <MenuRoot closeParentOnEsc={closeParentOnEsc} {...props} /> |
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.
macOS closes them all simultaneously; not sure if this should change as a default
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.
According to the MDN documentation, pressing ESC in a submenu should return focus to the parent menu or menuitem.
I've implemented this as the default behavior for submenus based on that recommendation.
I'm curious to hear your thoughts on this.
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.
I'm not too fussed either way, and am ok with changing it if this default is better suited in the web paradigm cc: @colmtuite
closeParentOnEsc default valuecloseParentOnEsc default value
closeParentOnEsc default valuecloseParentOnEsc default value
LukasTy
left a comment
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.
LGTM. 👌
Thank you for the contribution. 🙏
Co-authored-by: Lukas Tyla <llukas.tyla@gmail.com>
closed #2490
According to the MDN documentation, when the focus is on a submenu, pressing the ESC key should close the submenu and move focus to the submenu trigger.
Additionally, the Base UI documentation states that when the Esc key is pressed, the focus should return to the trigger element by default.
However, the current implementation has two issues:
closeParentOnEscis set tofalse, the root menu remains open, but the focus is lost completely.To resolve this, the following changes have been implemented:
false.