Skip to content

Commit 7a92bfd

Browse files
committed
Fix <AutocompleteArrayInput> does not apply ChipProps nor
`slotProps.chip` in `renderTags`
1 parent c66cd8c commit 7a92bfd

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

packages/ra-ui-materialui/src/input/AutocompleteArrayInput.stories.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react';
22
import { Admin } from 'react-admin';
33

44
import CloseIcon from '@mui/icons-material/Close';
5+
import BackspaceIcon from '@mui/icons-material/Backspace';
56
import {
67
Button,
78
Chip,
@@ -780,3 +781,20 @@ export const InsideReferenceArrayInputWithCreationSupport = () => (
780781
</Admin>
781782
</TestMemoryRouter>
782783
);
784+
785+
export const ChipProps = () => (
786+
<Wrapper>
787+
<AutocompleteArrayInput
788+
source="roles"
789+
choices={[
790+
{ id: 'admin', name: 'Admin' },
791+
{ id: 'u001', name: 'Editor' },
792+
{ id: 'u002', name: 'Moderator' },
793+
{ id: 'u003', name: 'Reviewer' },
794+
]}
795+
ChipProps={{
796+
deleteIcon: <BackspaceIcon />,
797+
}}
798+
/>
799+
</Wrapper>
800+
);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,11 @@ If you provided a React element for the optionText prop, you must also provide t
726726
value.map((option, index) => {
727727
// We have to extract the key because react 19 does not allow to spread the key prop
728728
const { key, ...tagProps } = getTagProps({ index });
729+
// @ts-expect-error slotProps do not yet exist in MUI v5
730+
const mergedSlotProps = props.slotProps?.chip
731+
? // @ts-expect-error slotProps do not yet exist in MUI v5
732+
props.slotProps.chip
733+
: props.ChipProps;
729734
return (
730735
<Chip
731736
label={
@@ -738,6 +743,7 @@ If you provided a React element for the optionText prop, you must also provide t
738743
size="small"
739744
key={key}
740745
{...tagProps}
746+
{...mergedSlotProps}
741747
/>
742748
);
743749
})

0 commit comments

Comments
 (0)