-
Notifications
You must be signed in to change notification settings - Fork 4.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
DropdownMenuV2: inherit placement for nested submenus #56213
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.
I'm a bit confused by both outcomes, to be honest! Either way, there are some issues with the keyboard navigation, which really are confusing, and which I would block this on. When the trigger is on the left...
When the trigger is on the right...
Evidently Ariakit tries to be smart about arrow keys, which I'm guessing is causing all of these issues. I'm not entirely sure why. I'd expect left and right to behave consistently (and flipped but still consistent when RTL), regardless of where the menu is visually. |
That seems to be triggered by Ariakit, since opening the DropdownMenu when
I had flagged this behaviour in ariakit/ariakit#3029, but it seems like this behaviour was intentional and aimed at aligning with how native submenus work on both macOS and Windows. Does that make sense to you? Feel free to reply to the ariakit issue in case you have any feedback to add. To solve this very same issue, in #55625 (comment) I had decided to apply an explicit |
I can't find anything specific from Apple on navigating menus with keyboards, but when a menu is close to the edge of the screen, right still opens submenus (visually to the left), and left closes them. Microsoft is also a little ambiguous on the matter:
IBM however is rather more explicit:
I'm not aware of an OS pattern that swaps this, outside of RTL contexts. The documentation is at least consistent in this though!
|
Thank you, @andrewhayward . I left a reply in the related ariakit issue. Specifically to this PR, I would argue that the issues with the keyboard navigation UX already affect In other words, I wonder if we could review this PR and potentially merge it without waiting on potential changes on the ariakit side. |
That's because there's padding in Storybook's |
Hey folks, do we think this PR can be landed, or is there too much skepticism around the proposed behaviour? |
I don't have a strong feeling either way to be honest. The overlapping menus is a bit awkward, but not the end of the world, especially if we can improve our elevation styles (shadows). Perhaps most importantly it feels consistent with the keyboard behavior which is something I don't think we should mess with – the W3 guidelines seem very sensible to me. |
Sounds good. I'm going to be closing this issue based on the overall skepticism around the keyboard interaction, and in the hope that we can deal better with overlapping submenus by tweaking the styles. |
What?
This PR proposes an additional piece of logic to the new experimental
DropdownMenu
component, by letting nested submenus inherit theplacement
from their parent menus.Why?
The idea is that having nested submenus opening in the same "direction" is easier for the users both in terms of how the UI looks, but also in terms of UX and a11y (especially keyboard navigation) — here's an example scenario.
How?
See above
Testing Instructions
placement
prop applied)Click to expand
placement
prop)placement
prop on the variousDropdownMenu
components, make sure that the prop always takes priority on the default behaviourScreenshots