react-admin
react-admin copied to clipboard
When 'name' field is null , Autocomplete optionText returns error even though i define inputText
What you were expecting:
What happened instead: AuAutocomplete components are directly using react-admin AutocompleteInput component. While we are getting 'name' field null it returns error which you can see above. Even though i define inputText , it still returns the same error. It seems that there is a bug . I tried to give component and function to optionText but all the time i got this error. Also 'code' field is always a string but it still not looking for condition.
Steps to reproduce: try to use null element
Related code:
<AuAutocomplete
defaultValue={'-'}
emptyValue={'-'}
optionText={(choice) => <div>{choice?.name ?? choice?.code}</div>}
inputText={(choice) => `${choice?.name} ${choice?.code}`}
optionValue="daprAppId"
label="Domain"
filterToQuery={(q: string) => ({ name: q })}
/>
Other information:
Environment
- React-admin version: "react-admin": "^4.16.1",
- Last version that did not exhibit the issue (if applicable):
- React version: "react": "^18.2.0",
- Browser:chrome
- Stack trace (in case of a JS error):
I had a similar problem and could not solve it. I hope the problem will be solved and I will update.
I'm sorry, I don't understand your issue. Please rephrase and provide a reproduction based on the simple example Codesandbox (https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple) or on the Storybook for option text element (https://react-admin-storybook.vercel.app/?path=/story/ra-ui-materialui-input-autocompleteinput--option-text-element)
https://github.com/marmelab/react-admin/blob/b6554db5b9e1516bd3b83cf4a26d2d1259c4c25c/packages/ra-ui-materialui/src/input/AutocompleteInput.stories.tsx#L184-L208
No news for some time, closing.