diff --git a/src/components/SearchInput.jsx b/src/components/SearchInput.jsx index f5305e5..e2b488d 100644 --- a/src/components/SearchInput.jsx +++ b/src/components/SearchInput.jsx @@ -18,7 +18,10 @@ function DebounceSelect({ fetchOptions, debounceTimeout = 500, initLoad = false, const loadOptions = (value) => { fetchRef.current += 1; const fetchId = fetchRef.current; - if (value) setOptions([]); + const currentFilter = options.filter(option => (option?.label ?? '').toLowerCase().includes(value.toLowerCase())) + if (currentFilter.length!==0) { setOptions(currentFilter); return; } + else if (value) setOptions([]); + // if (value) setOptions([]); setFetching(true); fetchOptions(value).then((newOptions) => { const mapperOptions = newOptions.map(ele => objectMapper(ele, props.map)); @@ -36,6 +39,11 @@ function DebounceSelect({ fetchOptions, debounceTimeout = 500, initLoad = false, return debounce(loadOptions, debounceTimeout); }, [fetchOptions, debounceTimeout]); + const onChange = (v) => { + props.onChange && props.onChange(v); + setOptions(defaultOptions); + } + return (