Skip to content

Conversation

@ZeeshanTamboli
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli commented Jan 6, 2026

Regression from #47380.

Resolves issue #47423 (comment).

The activeElement is captured once when the effect runs, and then reused for every later keydown.

Because that activeElement value is stale, if the dialog initially focused rootRef.current (common when it opens), then every later Shift+Tab keydown still thinks the origin is the root so it forces focus to sentinelEnd, which then causes the trap to wrap focus to the last tabbable element ("Agree"), making it look "stuck".


Before: https://mui.com/material-ui/react-dialog/#transitions
After: https://deploy-preview-47566--material-ui.netlify.app/material-ui/react-dialog/#transitions

@ZeeshanTamboli ZeeshanTamboli added scope: focus trap Changes related to the focus trap. type: regression A bug, but worse, it used to behave as expected. labels Jan 6, 2026
@mui-bot
Copy link

mui-bot commented Jan 6, 2026

Netlify deploy preview

https://deploy-preview-47566--material-ui.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/material 🔺+2B(0.00%) 🔺+2B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against d1659ba

Copy link
Contributor

@sai6855 sai6855 left a comment

Choose a reason for hiding this comment

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

👍

@ZeeshanTamboli ZeeshanTamboli merged commit cb4d8ac into mui:master Jan 6, 2026
19 checks passed
@ZeeshanTamboli ZeeshanTamboli deleted the focus-trap-regression-activeElement-stale branch January 6, 2026 08:44
@ZeeshanTamboli ZeeshanTamboli mentioned this pull request Jan 8, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: focus trap Changes related to the focus trap. type: regression A bug, but worse, it used to behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants