Skip to content

Commit 048d39f

Browse files
authored
Merge pull request #10793 from marmelab/fix-AutocompleteInput-slotProps-override
Fix `<AutocompleteInput>` should not break when overriding input slot props
2 parents fe5e053 + 3d85f04 commit 048d39f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/ra-ui-materialui/src/input/AutocompleteInput.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,21 @@ If you provided a React element for the optionText prop, you must also provide t
628628
...params.InputProps,
629629
...TextFieldProps?.InputProps,
630630
};
631+
// @ts-expect-error slotProps do not yet exist in MUI v5
632+
const mergedSlotProps = TextFieldProps?.slotProps
633+
? {
634+
slotProps: {
635+
// @ts-expect-error slotProps do not yet exist in MUI v5
636+
...TextFieldProps?.slotProps,
637+
input: {
638+
readOnly,
639+
...params.InputProps,
640+
// @ts-expect-error slotProps do not yet exist in MUI v5
641+
...TextFieldProps?.slotProps?.input,
642+
},
643+
},
644+
}
645+
: undefined;
631646
return (
632647
<TextField
633648
name={field.name}
@@ -663,6 +678,7 @@ If you provided a React element for the optionText prop, you must also provide t
663678
{...params}
664679
{...TextFieldProps}
665680
InputProps={mergedTextFieldProps}
681+
{...mergedSlotProps}
666682
size={size}
667683
inputRef={handleInputRef}
668684
/>

0 commit comments

Comments
 (0)