-
Notifications
You must be signed in to change notification settings - Fork 1.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
fix(menu): render through portal to avoid z-index and overflow issues #8829
Conversation
✔️ Deploy Preview for carbon-elements ready! 🔨 Explore the source changes: 5072497 🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-elements/deploys/60edde47de1a9700082703de 😎 Browse the preview: https://deploy-preview-8829--carbon-elements.netlify.app |
✔️ Deploy Preview for carbon-components-react ready! 🔨 Explore the source changes: 5072497 🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-components-react/deploys/60edde472a3ffc000748e6cd 😎 Browse the preview: https://deploy-preview-8829--carbon-components-react.netlify.app |
@janhassel in the past we got tripped up with portals (specifically the AC violation that content should be rendered in a landmark) and I was curious if this approach handles the use-case where screen reader uses can exit the menu with their virtual cursor and end up in a part of the document that they don't expect? For an example, I wrote a bit about this over in: #7565 (comment) and just was curious if this approach was using an |
@joshblack Good point! I only thought of the focus management so far but not about the virtual screen reader cursor. Just pushed an update with <div aria-owns="menu-id">
<button>...</button>
</div> I don't think this should cause any issues though as I set Could you check if the update works for you? |
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.
@sstrubberg Good catch! Should be fixed now. |
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.
Should focus return to the trigger element after an item is selected in the menu? Here I select one and then hit tab, which places focus on the first tab stop.
doesnt.return.to.trigger.element.mov
EDIT - I'm also I'm seeing the same with the voiceover virtual cursor. Here I start on the default OverflowMenu - I select an option from the list, hit tab, focus is returned to the trigger element. On the Menu "In Toolbar" story it goes back to the first tab stop instead of the trigger element
same.with.virtual.voiceover.cursor.mov
✔️ Deploy Preview for carbon-react-next ready! 🔨 Explore the source changes: 5072497 🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-react-next/deploys/60eeefd7399d09446a0b6491 😎 Browse the preview: https://deploy-preview-8829--carbon-react-next.netlify.app |
@tay1orjones Apologies for the long delay! I just pushed an update which returns the focus to the trigger (if any) whenever the menu is closed. It should work with both mouse and keyboard operation (including VoiceOver controls). |
Just a quick note, before merging we should give @janhassel a heads up so he can toggle off the demo story that he wrote 👀 |
Renders the
Menu
component through a portal to avoid it being misplaced, cut off or invisible in certain setups (such as the DataTable toolbar).Changelog
Changed
Menu
throughReactDOM.createPortal()
Testing / Reviewing
blur
, the focus is returned to the trigger element (if any exists)