Closed Guy-Adler closed 2 years ago
As a workaround, one can use
const buildOption = (choice: any) => {
if (choice.name !== undefined) {
return choice.name;
}
return whatever you want;
};
however, this is very confusing
Bug reproduced, thanks for your report 👍
What you were expecting:
When passing the
create
property toAutocompleteInput
, the default text for the creation option should bera.action.create_item
.What happened instead:
The text was
undefined
.Steps to reproduce:
optionText
prop is a function.Related code:
Code sandbox: https://codesandbox.io/s/fervent-breeze-muqxj4?file=/src/posts/TagReferenceInput.tsx
The change was made on lines 48:
Other information:
This is probably caused by line 84 of https://github.com/marmelab/react-admin/blob/58f9841d1fd7dbb3132376b6c50a2b0dd3ca4b8b/packages/ra-ui-materialui/src/input/useSupportCreateSuggestion.tsx#L69-L77 when passing optionText as a function, the string is always saved under
name
, which makes it impossible to use a combination of fields as the option text.Environment