From 9e9fa16a3fdc27a5b275402fc20ff5a023cd86ee Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Wed, 20 Sep 2023 03:47:48 +0530 Subject: [PATCH] Medibase Search: Skip showing selected option search results when query is present (#6284) * fixes #6283; skip showing selected option in medibase search * fix onblur --- src/Components/Form/FormFields/Autocomplete.tsx | 1 + src/Components/Medicine/MedibaseAutocompleteFormField.tsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Components/Form/FormFields/Autocomplete.tsx b/src/Components/Form/FormFields/Autocomplete.tsx index dcf3ab5e8b6..bbc60643faf 100644 --- a/src/Components/Form/FormFields/Autocomplete.tsx +++ b/src/Components/Form/FormFields/Autocomplete.tsx @@ -157,6 +157,7 @@ export const Autocomplete = (props: AutocompleteProps) => { placeholder={props.placeholder ?? "Select"} displayValue={(value: any) => value?.label || ""} onChange={(event) => setQuery(event.target.value.toLowerCase())} + onBlur={() => value && setQuery("")} autoComplete="off" /> diff --git a/src/Components/Medicine/MedibaseAutocompleteFormField.tsx b/src/Components/Medicine/MedibaseAutocompleteFormField.tsx index 337546691f9..2b5612f6f32 100644 --- a/src/Components/Medicine/MedibaseAutocompleteFormField.tsx +++ b/src/Components/Medicine/MedibaseAutocompleteFormField.tsx @@ -49,7 +49,7 @@ export default function MedibaseAutocompleteFormField( value={field.value} required onChange={field.handleChange} - options={options(field.value && [field.value])} + options={options(field.value && !query && [field.value])} optionLabel={(option) => option.name.toUpperCase()} optionDescription={(option) => } optionValue={(option) => option}