Skip to content

Commit

Permalink
Disconnect hospital or physician if user clears input field
Browse files Browse the repository at this point in the history
  • Loading branch information
samau3 committed Oct 20, 2024
1 parent e0ff6ea commit 7101186
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ export default function SearchDatabaseInputField({
combobox.updateSelectedOptionIndex();
combobox.openDropdown();
}}
onKeyDown={(event) => {
const { key, target } = event;
const { value, selectionStart, selectionEnd } = target;
// Check if the entire input is selected or if there is one or fewer characters
if (
key === 'Backspace' &&
(value.length <= 1 ||
(selectionStart === 0 && selectionEnd === value.length))
) {
event.preventDefault();
fetchOptions('');
handleSelectValue('', '');
}
}}
rightSection={loading ? <Loader size="xs" /> : null}
/>
</Combobox.EventsTarget>
Expand Down

0 comments on commit 7101186

Please sign in to comment.