Steps to reproduce
We were unable to reduce this to a minimal sandbox in isolation (a 2-3 field form without other context does not reproduce it) — it reliably reproduces in a full application form with:
- A
react-hook-form form, mode: 'onChange', resolver from @hookform/resolvers/yup (async, even for a purely synchronous schema — yupResolver always returns a Promise).
- Several
TextField/Select (MUI) fields validated via Controller, filled in first via userEvent.
- A
DatePicker/DateField field filled in afterward via userEvent.click() + userEvent.keyboard() + userEvent.tab() (or .type(), or .paste()).
- Run under Vitest + jsdom +
@testing-library/react.
I'm happy to work with a maintainer to build a precise minimal sandbox if the above isn't enough to reproduce on your end — will follow up if I manage to isolate it further.
Current behavior
When a DatePicker/DateField is used inside a form validated with react-hook-form + an async resolver (e.g. @hookform/resolvers/yup), interacting with the date field via @testing-library/user-event after other fields have already been filled in produces recurring React warnings in @mui/x-date-pickers(-pro) 9.7.0 and later:
An update to ForwardRef(FormControl) inside a test was not wrapped in act(...).
An update to DateField inside a test was not wrapped in act(...).
A component suspended inside an `act` scope, but the `act` call was not awaited.
This does not happen on 9.6.0. I bisected every 9.x release between 9.6.0 and 9.13.0 and confirmed the warnings start appearing exactly at 9.7.0.
Diffing the published 9.6.0 vs 9.7.0 tarballs, the change is in internals/hooks/useField/useFieldRootProps.mjs, introduced by #22285 ("Avoid focusing the field on blank space clicks"). Before that PR, a single synchronous handleClick set focused/section state. After it, the work is split between a new handleMouseDown and a reduced handleClick, and click-driven section selection is deferred via containerClickTimeout.start(0, ...). This PR's own inline comment even calls out test environments:
"This branch only matters for click events that arrive without a preceding mousedown (programmatic element.click(), some assistive-technology activations, synthetic event sequences in tests)."
I could not reduce this to a small, fully isolated sandbox (a bare form with 2-3 fields does not reproduce it), but it reproduces reliably and repeatedly (dozens of times, across ~40 different test files) in our real application's forms, which:
- Use
react-hook-form with mode: 'onChange' and an async (yupResolver) validation resolver.
- Have several
TextField/Select fields validated before the user reaches a DatePicker field.
- Drive the date field via
userEvent.click() + userEvent.keyboard() + userEvent.tab() (also reproduces with userEvent.type() on the field group, and with userEvent.paste() instead of keyboard() — so it is not specific to how the value is typed).
Things I ruled out as the cause (all still reproduce the warning):
- Using a single atomic
userEvent.type(group, dateString) call instead of separate click/keyboard/tab calls.
- Using
userEvent.paste() instead of userEvent.keyboard().
- Wrapping the interaction in an explicit
act(async () => { ... }) — this either doesn't help, or (when a Select was touched shortly before) produces a worse warning: The current testing environment is not configured to support act(...), appearing many times.
- Flushing pending timers with
act() before/after the interaction, at every step, and with vi.useFakeTimers() + deterministic timer advancement.
- Wrapping the field in a
Dialog (in case FocusTrap timing was involved).
Expected behavior
Interacting with a DateField/DatePicker via @testing-library/user-event, in a form with other already-validated fields, should not produce React act() warnings, matching the behavior on 9.6.0.
Context
Upgrading @mui/x-date-pickers-pro (and the other @mui/x-* packages) from an older pinned set of versions to the latest, and needed to determine why our test suite started emitting act() warnings across ~40 test files after the upgrade.
Your environment
npx @mui/envinfo
System:
OS: macOS
Binaries:
Node: 24.x
npm: 11.x
Browsers:
(jsdom via Vitest, not a real browser)
npmPackages:
@emotion/react: 11.14.0
@emotion/styled: 11.14.1
@mui/material: 9.4.0
@mui/x-date-pickers-pro: 9.7.0 through 9.13.0 (reproduces on all; 9.6.0 is clean)
@hookform/resolvers: 5.7.1
react: 19.2.8
react-dom: 19.2.8
react-hook-form: 7.85.0
yup: 1.7.1
@testing-library/react: 16.3.2
@testing-library/user-event: 14.6.3
vitest: 4.1.11
jsdom: 26.1.0
Search keywords: DateField act warning useFieldRootProps
Steps to reproduce
We were unable to reduce this to a minimal sandbox in isolation (a 2-3 field form without other context does not reproduce it) — it reliably reproduces in a full application form with:
react-hook-formform,mode: 'onChange', resolver from@hookform/resolvers/yup(async, even for a purely synchronous schema —yupResolveralways returns a Promise).TextField/Select(MUI) fields validated viaController, filled in first viauserEvent.DatePicker/DateFieldfield filled in afterward viauserEvent.click()+userEvent.keyboard()+userEvent.tab()(or.type(), or.paste()).@testing-library/react.I'm happy to work with a maintainer to build a precise minimal sandbox if the above isn't enough to reproduce on your end — will follow up if I manage to isolate it further.
Current behavior
When a
DatePicker/DateFieldis used inside a form validated withreact-hook-form+ an async resolver (e.g.@hookform/resolvers/yup), interacting with the date field via@testing-library/user-eventafter other fields have already been filled in produces recurring React warnings in@mui/x-date-pickers(-pro)9.7.0 and later:This does not happen on 9.6.0. I bisected every 9.x release between 9.6.0 and 9.13.0 and confirmed the warnings start appearing exactly at 9.7.0.
Diffing the published 9.6.0 vs 9.7.0 tarballs, the change is in
internals/hooks/useField/useFieldRootProps.mjs, introduced by #22285 ("Avoid focusing the field on blank space clicks"). Before that PR, a single synchronoushandleClicksetfocused/section state. After it, the work is split between a newhandleMouseDownand a reducedhandleClick, and click-driven section selection is deferred viacontainerClickTimeout.start(0, ...). This PR's own inline comment even calls out test environments:I could not reduce this to a small, fully isolated sandbox (a bare form with 2-3 fields does not reproduce it), but it reproduces reliably and repeatedly (dozens of times, across ~40 different test files) in our real application's forms, which:
react-hook-formwithmode: 'onChange'and an async (yupResolver) validation resolver.TextField/Selectfields validated before the user reaches aDatePickerfield.userEvent.click()+userEvent.keyboard()+userEvent.tab()(also reproduces withuserEvent.type()on the field group, and withuserEvent.paste()instead ofkeyboard()— so it is not specific to how the value is typed).Things I ruled out as the cause (all still reproduce the warning):
userEvent.type(group, dateString)call instead of separate click/keyboard/tab calls.userEvent.paste()instead ofuserEvent.keyboard().act(async () => { ... })— this either doesn't help, or (when aSelectwas touched shortly before) produces a worse warning:The current testing environment is not configured to support act(...), appearing many times.act()before/after the interaction, at every step, and withvi.useFakeTimers()+ deterministic timer advancement.Dialog(in caseFocusTraptiming was involved).Expected behavior
Interacting with a
DateField/DatePickervia@testing-library/user-event, in a form with other already-validated fields, should not produce Reactact()warnings, matching the behavior on 9.6.0.Context
Upgrading
@mui/x-date-pickers-pro(and the other@mui/x-*packages) from an older pinned set of versions to the latest, and needed to determine why our test suite started emittingact()warnings across ~40 test files after the upgrade.Your environment
npx @mui/envinfoSearch keywords: DateField act warning useFieldRootProps