Skip to content
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

Dropdown - fix dropdown content not being preserved when interacted with #2506

Merged
merged 3 commits into from
Oct 15, 2024

Conversation

alex-ju
Copy link
Member

@alex-ju alex-ju commented Oct 15, 2024

πŸ“Œ Summary

Fixed an issue where the dropdown content was not preserved when interacted with.

πŸ› οΈ Detailed description

The PopoverPrimitive assumes the popover element is focusable and registers a focusout event on the main popover container to determine when to hide the container. When the popover element is not focusable, any interaction will trigger a focusout and close the popover. To resolve this we make the popover container focusable using tabindex="-1".

πŸ”— External links

Jira ticket: HDS-3994


πŸ‘€ Component checklist

πŸ’¬ Please consider using conventional comments when reviewing this PR.

Copy link

vercel bot commented Oct 15, 2024

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Updated (UTC)
hds-showcase βœ… Ready (Inspect) Visit Preview Oct 15, 2024 10:02am
hds-website βœ… Ready (Inspect) Visit Preview Oct 15, 2024 10:02am

@@ -13,6 +13,7 @@
)
}}
<div
tabindex="-1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I noticed the other day when doing the code review, that this tabindex was missing: https://github.com/hashicorp/design-system/blob/main/packages/components/src/components/hds/menu-primitive/index.hbs#L16

(but then I thought we would have noticed if it was important, so I didn't say anything; well, we noticed πŸ€¦β€β™‚οΈ)

The PopoverPrimitive assumes the popover element is focusable and registers a focusout event on the main popover container to determine when to hide the container. When the popover element is not focusable any event will trigger a focusout and close the popover. To resolve this we make the popover container focusable using `tabindex="-1"`
@alex-ju alex-ju force-pushed the alex-ju/dropdown-focusout-fix branch from 29392da to 68348f9 Compare October 15, 2024 09:57
@alex-ju alex-ju merged commit c481aa6 into main Oct 15, 2024
14 checks passed
@alex-ju alex-ju deleted the alex-ju/dropdown-focusout-fix branch October 15, 2024 10:12
@hashibot-hds hashibot-hds mentioned this pull request Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants