fix(mui): support MUI v7+ slotProps in Autocomplete renderInput - #1325
Open
tangentlin wants to merge 1 commit into
Open
fix(mui): support MUI v7+ slotProps in Autocomplete renderInput#1325tangentlin wants to merge 1 commit into
tangentlin wants to merge 1 commit into
Conversation
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
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
|
@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. |
|
Is the repo still beeing maintained - be a shame if it was'nt just for MUI compatability as the rest works well |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MuiAutocomplete'srenderInputreadsparams.InputProps.endAdornment. In MUI v7 the AutocompleterenderInputparams replacedInputProps/inputPropswithslotProps.input/slotProps.htmlInput, so on MUI v7+ (including v9)params.InputPropsisundefinedand this throwsTypeError: 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:
params.slotPropsundefined): sameinputProps/InputPropsshape and merge order as before — no behavior change.params.slotPropspresent): writesslotProps.htmlInput/slotProps.inputand reads the inherited end adornment fromslotProps.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 passInputProps/inputPropstoTextField, 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
muipackage in this monorepo (which resolves@mui/material@6.3.1in 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+
slotPropsbranch was reviewed by inspection (matching MUI's documented v7renderInputparams change) rather than exercised at runtime here. The v5/v6 branch preserves the originalinputProps/InputPropsshape and merge order, so existing behavior is unchanged. A full test-suite / browser run across MUI v7+ was not performed.