Fix <AutocompleteInput> should not break when overriding input slot props#10793
Merged
Fix <AutocompleteInput> should not break when overriding input slot props#10793
<AutocompleteInput> should not break when overriding input slot props#10793Conversation
djhi
approved these changes
Jun 20, 2025
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.
Problem
Fix #10789
With MUI v6 or v7, passing custom input slot props to
<AutocompleteInput>breaks its autocomplete feature (the dropdown list doesn't open anymore)Solution
With MUI v6 or v7 the InputProps need to be forwarded as
slotProps.input(as opposed toInputPropswith MUI v5). With the previous implementation, passing customslotProps.inputasTextFieldPropswould completely override theslotPropsand hence loose the params injected by MUI.The solution consists in injecting the input props at both places, to support all MUI versions.
The only catch is we should only pass a
slotPropsprop if one was passed toTextFieldProps(i.e. if the user is using the v6/v7 syntax), otherwise we would get a warning about unknow propslotPropswith MUI v5.How To Test
To test backward compatibility with MUI v5
Edit
examples/simple/src/posts/PostCreate.tsxwith the following:<AutocompleteInput label="User" create={<CreateUser />} openOnFocus={false} + TextFieldProps={{ + InputProps: { + startAdornment: <BookIcon />, + }, + }} />Run
make run.Make sure the input still works and the icon is present.
To test forward compatibility with MUI v7
Edit
examples/demo/src/reviews/ReviewCreate.tsxwith the following:<AutocompleteInput optionText="reference" validate={required()} + TextFieldProps={{ + slotProps: { + input: { + startAdornment: <BookIcon />, + }, + }, + }} />You may get a TS error about unknown prop
slotProps, but this is due to the IDE not properly resolving multiple versions of the MUI types (i.e. it's a monorepo only issue).You can safely ignore that warning.
Run
make run-demo.Make sure the input still works and the icon is present.
Additional Checks
masterfor a bugfix or a documentation fix, ornextfor a featureAlso, please make sure to read the contributing guidelines.