-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: Fix focus management for dismissible tags #19355
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: Fix focus management for dismissible tags #19355
Conversation
✅ Deploy Preview for v11-carbon-web-components ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for v11-carbon-react ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #19355 +/- ##
=======================================
Coverage 84.46% 84.46%
=======================================
Files 373 373
Lines 14640 14640
Branches 4837 4810 -27
=======================================
Hits 12366 12366
+ Misses 2127 2126 -1
- Partials 147 148 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Why not just focus the next or previous focusable element? It seems like you aren't handling the corner case where the user deletes the last tag. |
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.
Works well
if (nextCloseIcon) { | ||
setTimeout(() => { | ||
nextCloseIcon.focus(); | ||
}, 0); |
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.
Hey, Could you check if setTimeout
is really needed here? It seems to be working fine for me without it. Do we need it for any specific case or scenario?
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.
@preetibansalui Without the timeout, the focus might be set before other event handlers have completed processing the current event.
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.
Can we add some checks to prevent it from being set before the others? I don't have an issue with using setTimeout
but I just want to make sure it's truly necessary in this case.
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.
LGTM
0c8f711
Closes #19269
Fix focus management for dismissible tags
Changelog
New
Testing / Reviewing