Skip to content

Fix drawer initial focus when opened - #43139

Open
Fire162 wants to merge 1 commit into
twbs:mainfrom
Fire162:fix-drawer-initial-focus
Open

Fire162 wants to merge 1 commit into
twbs:mainfrom
Fire162:fix-drawer-initial-focus

Conversation

@Fire162

@Fire162 Fire162 commented Oct 21, 2026

Copy link
Copy Markdown

Description

  • Make drawer direct children visible when opening or hiding in scss/_drawer.scss.

Motivation & Context

  • When a drawer opens via showModal(), the browser runs dialog focusing steps synchronously at time t = 0.
  • Because closed drawers use visibility: hidden and animate visibility alongside transform via transitions, the drawer remains visibility: hidden at time t = 0.
  • Descendant elements inherit visibility: hidden at that instant and are treated as non-focusable, causing initial focus to fall back to <body> instead of moving into the drawer.
  • Adding &:is([open], .hiding) > * { visibility: visible; } makes drawer children immediately visible without waiting on the drawer's transition interpolation, allowing initial focus to land on the first focusable descendant.
  • npm run lint, npm run css-test, and npm run js-test pass locally.

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

Related issues

Fixes #43120

@Fire162
Fire162 requested a review from a team as a code owner October 21, 2026 00:40
@julien-deramond julien-deramond added v6 v6, the main branch accessibility Keyboard, screen readers, contrast, ARIA bug Something does not work as documented css Sass sources or compiled CSS labels Oct 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility Keyboard, screen readers, contrast, ARIA bug Something does not work as documented css Sass sources or compiled CSS v6 v6, the main branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v6: Drawer doesn't move focus inside when opened (visibility is still hidden at showModal())

2 participants