Skip to content

[input base] Fix "Maximum update depth exceeded" error with a start adornment - #49703

Merged
ZeeshanTamboli merged 4 commits into
mui:masterfrom
leshaduduk:inputbase-skip-unchanged-adornedstart
Nov 17, 2026
Merged

ZeeshanTamboli merged 4 commits into
mui:masterfrom
leshaduduk:inputbase-skip-unchanged-adornedstart

Conversation

@leshaduduk

@leshaduduk leshaduduk commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #49701

InputBase syncs adornedStart to its FormControl in an effect that depended on the startAdornment element and the whole context value. An inline adornment is a new element on every render, and in development the context value is also new on every render. So the effect called setAdornedStart with an unchanged value on every render. With React 19, fast re-renders (for example, typing quickly in a large form) pile up these updates until React throws "Maximum update depth exceeded".

The effect now depends on Boolean(startAdornment) and the stable setAdornedStart setter, so it runs only when the adornment appears or disappears.

The effect that calls `muiFormControl.setAdornedStart` re-runs whenever
`startAdornment` is a new element, which is the case for inline JSX on
every render. Calling it with the same value can still schedule a render
of the FormControl when the fiber has pending lanes. React 19 counts
such a default-priority update, left pending after a synchronous commit,
as a nested update, so fast typing throws "Maximum update depth
exceeded".

Call `setAdornedStart` only when the value differs from the one in the
FormControl context.
@code-infra-dashboard

code-infra-dashboard Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Deploy preview

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

Bundle size

Bundle Parsed size Gzip size
@mui/material 🔺+23B(0.00%) 🔺+18B(+0.01%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 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

Performance

No regressions in 32 benchmarks · ran 4m 02s · details


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

@zannager zannager added package: material-ui Specific to Material UI. component: FormControl The React component. and removed package: material-ui Specific to Material UI. labels Nov 10, 2026
@ZeeshanTamboli ZeeshanTamboli added type: bug It doesn't behave as expected. needs cherry-pick The PR should be cherry-picked to master after merge. scope: input Changes related to the input. v9.x and removed component: FormControl The React component. labels Nov 17, 2026
@ZeeshanTamboli ZeeshanTamboli changed the title [material-ui][InputBase] Skip setting an unchanged adornedStart [input base] Fix "Maximum update depth exceeded" error with a start adornment Nov 17, 2026

@ZeeshanTamboli ZeeshanTamboli left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! The effect now runs only when the start adornment appears or disappears, so an inline adornment no longer triggers a no-op setAdornedStart on every render. That fixes the "Maximum update depth exceeded" crash with React 19, and unlike the earlier guard, it can't loop when two inputs share one FormControl. Related input tests pass locally. LGTM, and good to cherry-pick to v9.x. I also updated the PR description.

@ZeeshanTamboli
ZeeshanTamboli enabled auto-merge (squash) November 17, 2026 09:40
@ZeeshanTamboli
ZeeshanTamboli merged commit 0d7a3c2 into mui:master Nov 17, 2026
20 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Cherry-pick PRs will be created targeting branches: v9.x

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

Labels

needs cherry-pick The PR should be cherry-picked to master after merge. scope: input Changes related to the input. type: bug It doesn't behave as expected. v9.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[material-ui][InputBase][Popper] React 19: "Maximum update depth exceeded" when a form re-renders fast (same-value setState in effects)

3 participants