-
Notifications
You must be signed in to change notification settings - Fork 12
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
Prevent focusing hidden/disabled elements #263
Conversation
🦋 Changeset detectedLatest commit: a54cafc 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 |
} | ||
}) | ||
|
||
observer.observe(container, { | ||
subtree: true, | ||
childList: true, | ||
attributeFilter: ['hidden', 'disabled'], | ||
attributeOldValue: true, |
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.
Will this narrow down the observed set of elements in the first place? Seems like the filter was broader and the attributeFilter
narrows it down. Just trying to understand how the observer works.
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.
attributeFilter
allows us to watch for any changes of the attributes in the array, in addition to the rules that we already have. So it won't narrow our existing ruleset down, as it will still only run the callback if either a node is added/removed (childList
), or if an element receives/removes the hidden
, or disabled
attributes within the container. This essentially just slightly widens what we watch for.
Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days. |
Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days. |
Hey team! I was wondering if I could get a review on this PR? For context it's making sure that @primer/engineer-reviewers |
Closes #257
This PR attempts to address the issue where if an element is disabled or hidden after the
focusZone
function has ran, the focus trap no longer works. I've adjusted the mutation observer that watches for added or removed nodes within thefocusZone
container to now track thehidden
anddisabled
attributes.If either attribute is applied or removed, they will added/removed from the focus trap respectively.