Skip to content

fix(mui): support MUI v7+ slotProps in Autocomplete renderInput - #1325

Open
tangentlin wants to merge 1 commit into
ukrbublik:masterfrom
tangentlin:fix/mui-autocomplete-v7-slotprops
Open

fix(mui): support MUI v7+ slotProps in Autocomplete renderInput#1325
tangentlin wants to merge 1 commit into
ukrbublik:masterfrom
tangentlin:fix/mui-autocomplete-v7-slotprops

Conversation

@tangentlin

Copy link
Copy Markdown

Summary

MuiAutocomplete's renderInput reads params.InputProps.endAdornment. In MUI v7 the Autocomplete renderInput params replaced InputProps/inputProps with slotProps.input/slotProps.htmlInput, so on MUI v7+ (including v9) params.InputProps is undefined and this throws TypeError: Cannot read properties of undefined (reading 'endAdornment'), crashing any Autocomplete value widget.

This change detects the params shape at runtime and emits the matching props:

  • MUI v5/v6 (params.slotProps undefined): same inputProps/InputProps shape and merge order as before — no behavior change.
  • MUI v7+ (params.slotProps present): writes slotProps.htmlInput/slotProps.input and reads the inherited end adornment from slotProps.input.

It is scoped to the single crashing widget and does not change peerDependencies, so it is backward-compatible with the currently supported MUI range.

Fixes #1324

Note on other widgets

The other MUI value widgets (MuiText, MuiNumber, MuiTextArea, MuiPrice, MuiRange, MuiSlider) also pass InputProps/inputProps to TextField, which MUI v7+ ignores (degraded behavior rather than a crash). Full MUI 7+ support across all widgets is tracked separately in #1298; this PR intentionally stays narrow and only fixes the reported crash.

Testing

Verified against the mui package in this monorepo (which resolves @mui/material@6.3.1 in dev — i.e. the v5/v6 code path is the one statically compiled here):

  • pnpm i — succeeded.
  • pnpm --filter @react-awesome-query-builder/mui run eslint — passed clean (exit 0).
  • pnpm --filter @react-awesome-query-builder/mui run tsc (tsc -p . --noEmit) — passed clean (exit 0), so the change introduces no new type/syntax errors.

Honest caveats: these are static gates only. Because dev resolves MUI v6, the v7+ slotProps branch was reviewed by inspection (matching MUI's documented v7 renderInput params change) rather than exercised at runtime here. The v5/v6 branch preserves the original inputProps/InputProps shape and merge order, so existing behavior is unchanged. A full test-suite / browser run across MUI v7+ was not performed.

MUI v7 replaced the Autocomplete renderInput params `InputProps`/`inputProps`
with `slotProps.input`/`slotProps.htmlInput`. Reading `params.InputProps.endAdornment`
therefore throws on MUI v7+ (incl. v9), crashing any Autocomplete value widget.
Detect the params shape and emit the correct props, keeping MUI v5/v6 behavior unchanged.

Fixes ukrbublik#1324
@codesandbox

codesandbox Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

@tangentlin is attempting to deploy a commit to the Denys Oblohin's projects Team on Vercel.

A member of the Team first needs to authorize it.

@JoeGaffney

Copy link
Copy Markdown

Is the repo still beeing maintained - be a shame if it was'nt just for MUI compatability as the rest works well

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MUI v9] Autocomplete value widget crashes — "Cannot read properties of undefined (reading 'endAdornment')" (renderInput uses removed InputProps API)

2 participants