-
Notifications
You must be signed in to change notification settings - Fork 538
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
DialogV2: re-set focusTrap when footer content changes #4779
Conversation
🦋 Changeset detectedLatest commit: 4d7eba0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I had to utilize |
size-limit report 📦
|
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.
Logic is sound. Just need to test for any performance implications
That is fair! Is there a good way to go about this outside of just testing existing dialogs? Another option is making this opt-in, but not too sure if that's the best route to take if we want this functionality by default 🤔 |
Can see how if the hook is called only when it should or also on every render or on unrelated changes inside the Dialog content. Dependency on a
I think this should be default as well |
Ooh i really like that idea! I wonder how eager should the observer be. We haven't received any performance concerns about focus zone yet, but it's also not a common use case where content of focus zone changes, so maybe we don't attribute it to the hook
I think that's totally fine, we maintain both libraries anyways 😄 |
Quick update, working on a fix in primer/behaviors: primer/behaviors#429. Basically adding a mutation observer that checks if the start or end sentinels are no longer at the start/end. |
👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/339024 |
@siddharthkp, tested this with the updated behaviors version & very lightly in dotcom (though I couldn't find too many dialogs). Doesn't look like there's much performance hit, as the likelihood of content being added before/after sentinels is low. In cases where elements are added after the focus trap, they will only be moved once once it's asserted that either the first child or last child in the focus trap is a I'm curious if there's any additional testing we should do, or if we should ship this change (with the behaviors bump). |
Great, thanks for making sure! I think it sounds good, let's ship it |
Closes https://github.com/github/primer/issues/3358 https://github.com/github/primer/issues/3356 https://github.com/github/primer/issues/3357 https://github.com/github/primer/issues/2480
Adds
footer
as a dependency ofuseFocusTrap
, ensures that if content is changed within either, focus trap will properly focus newly added focusable elements. Example story: Repro Multistep Dialog With Conditional Footer.Changelog
Changed
footer
touseFocusTrap
dependenciesautofocus
prop from storiesRollout strategy
Testing & Reviewing
Merge checklist