Skip to content

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

Merged

Conversation

riddhybansal
Copy link
Contributor

Closes #19269

Fix focus management for dismissible tags

Changelog

New

  • Improved accessibility by ensuring focus moves to next available tag when dismissing

Testing / Reviewing

  • Go to dismissable tags
  • Close the tags and see if focus shifts to next tag

@riddhybansal riddhybansal requested review from a team as code owners May 9, 2025 19:37
Copy link

netlify bot commented May 9, 2025

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit d6ddd1f
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-web-components/deploys/68370da55bfce4000851563a
😎 Deploy Preview https://deploy-preview-19355--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented May 9, 2025

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit d6ddd1f
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-react/deploys/68370da5e9f93000082d398d
😎 Deploy Preview https://deploy-preview-19355--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

codecov bot commented May 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.46%. Comparing base (733f1b2) to head (d6ddd1f).
Report is 16 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wkeese
Copy link
Contributor

wkeese commented May 12, 2025

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.

Copy link
Contributor

@Gururajj77 Gururajj77 left a 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);
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

@preetibansalui preetibansalui left a comment

Choose a reason for hiding this comment

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

LGTM

@riddhybansal riddhybansal added this pull request to the merge queue Jun 2, 2025
Merged via the queue into carbon-design-system:main with commit 0c8f711 Jun 2, 2025
37 checks passed
@riddhybansal riddhybansal deleted the Dismissable_tag_issue branch June 2, 2025 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: When closing the dismissible tag, the focus doesn't jump to next tag
4 participants