File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
packages/ra-ui-materialui/src/input Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ import {
3535 warning ,
3636 useGetRecordRepresentation ,
3737 useEvent ,
38+ OptionTextFunc ,
3839} from 'ra-core' ;
3940import {
4041 SupportCreateSuggestionOptions ,
@@ -163,7 +164,7 @@ export const AutocompleteInput = <
163164 onChange,
164165 onCreate,
165166 openText = 'ra.action.open' ,
166- optionText,
167+ optionText : optionTextProp ,
167168 optionValue,
168169 parse,
169170 resource : resourceProp ,
@@ -228,6 +229,11 @@ export const AutocompleteInput = <
228229 ...rest ,
229230 } ) ;
230231
232+ // Memoize optionText
233+ const optionTextEvent = useEvent ( optionTextProp as OptionTextFunc ) ;
234+ const optionText =
235+ typeof optionTextProp === 'function' ? optionTextEvent : optionTextProp ;
236+
231237 const finalChoices = useMemo (
232238 ( ) =>
233239 // eslint-disable-next-line eqeqeq
You can’t perform that action at this time.
0 commit comments