From 0a7fcbadb442499e76d9b8d675671f9fe4725539 Mon Sep 17 00:00:00 2001 From: AngeloStatescu <35111313+AngeloStatescu@users.noreply.github.com> Date: Thu, 12 Oct 2023 12:09:38 +0300 Subject: [PATCH] More descriptive Autocomplete noOptionsText --- src/components/inputs/Autocomplete/Autocomplete.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/inputs/Autocomplete/Autocomplete.tsx b/src/components/inputs/Autocomplete/Autocomplete.tsx index 8494118a..b356d3f3 100644 --- a/src/components/inputs/Autocomplete/Autocomplete.tsx +++ b/src/components/inputs/Autocomplete/Autocomplete.tsx @@ -40,7 +40,7 @@ const Autocomplete: React.FC> = ({ loadOptions, loading: receivedLoading, loadingText, - noOptionsText = 'No options', + noOptionsText, getOptionLabel, onChange, onInputChange, @@ -307,9 +307,14 @@ const Autocomplete: React.FC> = ({ [handleLoadOptions, hasMore, isPaginated] ) + const internalNoOptionsText = useMemo(() => { + if (isSearchable && loadOptions && asyncOptions.length === 0 && !localInput) return 'Type to search...' + return noOptionsText || 'No options' + }, [isSearchable, loadOptions, asyncOptions, localInput, noOptionsText]) + return ( {noOptionsText}} + noOptionsText={{internalNoOptionsText}} typographyContentColor={typographyContentColor} forcePopupIcon label={label}