Skip to content

[pickers] Prevent focus restoration from reopening picker - #23321

Open
JAYATIAHUJA wants to merge 2 commits into
mui:masterfrom
JAYATIAHUJA:fix-picker-focus-restoration
Open

[pickers] Prevent focus restoration from reopening picker#23321
JAYATIAHUJA wants to merge 2 commits into
mui:masterfrom
JAYATIAHUJA:fix-picker-focus-restoration

Conversation

@JAYATIAHUJA

Copy link
Copy Markdown

Summary

When a desktop picker closes after selecting a date, PickerPopper restores focus to the field. With keepOpenDuringFieldFocus, that programmatic focus was treated as user focus and immediately reopened the picker.

This change:

  • adds a private isRestoringFocusRef to the picker context
  • marks the focus restoration window in PickerPopper
  • prevents PickerFieldUI from reopening only during that programmatic restoration
  • adds regression coverage proving selection stays closed while later keyboard focus still opens the picker

Closes #23089

Changelog

[pickers] Prevent keepOpenDuringFieldFocus from reopening the picker after a selection closes it.

Testing

  • pnpm test:unit --project "x-date-pickers" --run <affected test files> --maxWorkers=1 — 39 tests passed
  • ESLint on the five changed files
  • pnpm --filter "@mui/x-date-pickers" run typescript
  • pnpm --filter "@mui/x-date-pickers-pro" run typescript
  • Prettier check on the five changed files

Local environment note: a complete serialized x-date-pickers run was also attempted and reported 11 failures in untouched MobileDateTimePicker/YearCalendar paths, primarily 5-second timeouts and Material UI transition act(...) warnings. The directly affected suites and static checks above are green.

@code-infra-dashboard

code-infra-dashboard Bot commented Aug 10, 2026

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-23321--material-ui-x.netlify.app/
QR code for https://deploy-preview-23321--material-ui-x.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-charts-premium 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers 🔺+183B(+0.09%) 🔺+60B(+0.10%)
@mui/x-date-pickers-pro 🔺+180B(+0.07%) 🔺+59B(+0.08%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)
@mui/x-scheduler 0B(0.00%) 0B(0.00%)
@mui/x-scheduler-premium 0B(0.00%) 0B(0.00%)
@mui/x-chat 0B(0.00%) 0B(0.00%)
@mui/x-license 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@JAYATIAHUJA

Copy link
Copy Markdown
Author

Follow-up on the initial browser CI failures: both Chromium jobs failed at the same immediate dialog-removal assertion while the popper exit transition was still running. I pushed 9ba4f80 to use the repository's established transition-safe waitFor pattern.

Verified locally after the change:

  • Chromium: 2/2 tests passed
  • jsdom: 2/2 tests passed
  • ESLint and Prettier passed
  • @mui/x-date-pickers and @mui/x-date-pickers-pro TypeScript checks passed

The required PR type-label check needs type: bug; I do not have permission to apply labels in the upstream repository.

@zannager zannager added the scope: pickers Changes related to the date/time pickers. label Aug 11, 2026
@LukasTy LukasTy added the type: regression A bug, but worse, it used to behave as expected. label Aug 14, 2026
@LukasTy LukasTy self-assigned this Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: pickers Changes related to the date/time pickers. 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.

[pickers] keepOpenDuringFieldFocus prevents the picker from closing on date selection (closes then instantly reopens)

3 participants