Skip to content

Prevent .visually-hidden overflowing children to become focusable #41286

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
merged 2 commits into from
May 4, 2025

Conversation

ffoodd
Copy link
Member

@ffoodd ffoodd commented Mar 11, 2025

Description

Prevent .visually-hidden overflow.

Motivation & Context

@keltroth demonstrated that .visually-hidden children become focusable when overflowing, but remains hidden—conducting to a focus loss. Here's a reduced test case on CodePen using Bootstrap.

Type of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would change existing functionality)

Checklist

  • I have read the contributing guidelines
  • My code follows the code style of the project (using npm run lint)
  • My change introduces changes to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Live previews

@ffoodd ffoodd self-assigned this Mar 11, 2025
@ffoodd ffoodd requested a review from a team as a code owner March 11, 2025 09:28
@ffoodd ffoodd changed the title fix(visually-hidden): prevent overflowing children to become focusable Prevent .visually-hidden overflowing children to become focusable Mar 11, 2025
@github-project-automation github-project-automation bot moved this to To do in v5.3.6 Apr 15, 2025
@julien-deramond julien-deramond moved this from To do to Needs review in v5.3.6 Apr 15, 2025
@mdo
Copy link
Member

mdo commented Apr 29, 2025

Ayyy good to see you @ffoodd! Before I merge, any idea if we can make this a more focused selector or should we just not care about the new universal selector?

@ffoodd
Copy link
Member Author

ffoodd commented Apr 29, 2025

The only thing I can see is direct children combinator, but honestly I don't think we should care. Complex DOM in a visually hidden element is a really bad idea.

Copy link
Member

@julien-deramond julien-deramond left a comment

Choose a reason for hiding this comment

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

I've run several manual tests and didn't encounter any issues with this modification, except in some extremely rare edge cases that shouldn't realistically occur (as @ffoodd noted in this comment).

Overall, I believe it's safe to move forward with merging this. If any unexpected breaking cases arise from the community, we could still address them with a patch.

@julien-deramond julien-deramond moved this from Needs review to Review in progress in v5.3.6 Apr 30, 2025
@julien-deramond julien-deramond requested a review from mdo May 1, 2025 18:59
@mdo mdo merged commit c5bec4e into main May 4, 2025
15 checks passed
@mdo mdo deleted the main-fod-better-visually-hidden branch May 4, 2025 20:21
@github-project-automation github-project-automation bot moved this from Review in progress to Done in v5.3.6 May 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants