Skip to content

Commit e6a41a6

Browse files
committed
fix BC when using custom renderOption and AutocompleteArrayInput test
1 parent 08f6549 commit e6a41a6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

packages/ra-core/src/form/choices/useChoices.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ export const useChoices = ({
5555
const getChoiceText = useCallback(
5656
choice => {
5757
if (choice?.id === createValue || choice?.id === createHintValue) {
58-
// For the create choice, we always use the name prop as text
59-
return get(choice, 'name');
58+
return get(
59+
choice,
60+
typeof optionText === 'string' ? optionText : 'name'
61+
);
6062
}
6163

6264
if (isValidElement<{ record: any }>(optionText)) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const useSupportCreateSuggestion = (
3939
createItemLabel,
4040
createValue = '@@ra-create',
4141
createHintValue = '@@ra-create-hint',
42+
optionText = 'name',
4243
filter,
4344
handleChange,
4445
onCreate,
@@ -61,7 +62,7 @@ export const useSupportCreateSuggestion = (
6162
? createHintValue
6263
: createValue,
6364
},
64-
'name',
65+
typeof optionText === 'string' ? optionText : 'name',
6566
filter && createItemLabel
6667
? translate(createItemLabel, {
6768
item: filter,

0 commit comments

Comments
 (0)