Skip to content

Commit

Permalink
🐛 Filter pre-existing selections from options
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Bolton <[email protected]>

Revert changes

Signed-off-by: Ian Bolton <[email protected]>
  • Loading branch information
ibolton336 committed Mar 20, 2024
1 parent da9da4c commit 3f84088
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions client/src/app/components/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,10 @@ export const Autocomplete: React.FC<IAutocompleteProps> = ({
}, [options, selections]);

const filteredOptions = useMemo(() => {
// No input so do not filter!
if (!inputValue) {
return options;
}

// filter to choose options that are 1. NOT selected, and 2. include the inputValue
return options.filter(
({ id, name }) =>
selections.findIndex((s) => s.id === id) === -1 &&
toString(name).toLowerCase().includes(inputValue.toLocaleLowerCase())
toString(name).toLowerCase().includes(inputValue.toLowerCase())
);
}, [options, selections, inputValue]);

Expand Down Expand Up @@ -191,7 +185,6 @@ export const Autocomplete: React.FC<IAutocompleteProps> = ({
if (!event || !itemId) {
return;
}

event.stopPropagation();
focusTextInput(true);
addSelectionByItemId(itemId);
Expand Down

0 comments on commit 3f84088

Please sign in to comment.