Skip to content
Snippets Groups Projects
Unverified Commit 89c065e4 authored by Matiss Janis Aboltins's avatar Matiss Janis Aboltins Committed by GitHub
Browse files

:bug: (autocomplete) fix multi-select (#947)

parent 6325a368
No related branches found
No related tags found
No related merge requests found
...@@ -126,6 +126,7 @@ function SingleAutocomplete({ ...@@ -126,6 +126,7 @@ function SingleAutocomplete({
onSelect, onSelect,
tableBehavior, tableBehavior,
value: initialValue, value: initialValue,
isMulti = false,
}) { }) {
const [selectedItem, setSelectedItem] = useState(() => const [selectedItem, setSelectedItem] = useState(() =>
findItem(strict, suggestions, initialValue), findItem(strict, suggestions, initialValue),
...@@ -174,7 +175,12 @@ function SingleAutocomplete({ ...@@ -174,7 +175,12 @@ function SingleAutocomplete({
onSelect={(item, { inputValue }) => { onSelect={(item, { inputValue }) => {
setSelectedItem(item); setSelectedItem(item);
setHighlightedIndex(null); setHighlightedIndex(null);
setIsOpen(false);
if (isMulti) {
setValue('');
} else {
setIsOpen(false);
}
if (onSelect) { if (onSelect) {
// I AM NOT PROUD OF THIS OK?? // I AM NOT PROUD OF THIS OK??
...@@ -267,9 +273,6 @@ function SingleAutocomplete({ ...@@ -267,9 +273,6 @@ function SingleAutocomplete({
) { ) {
setHighlightedIndex(changes.highlightedIndex); setHighlightedIndex(changes.highlightedIndex);
} }
if ('isOpen' in changes) {
setIsOpen(embedded ? true : changes.isOpen);
}
if ('selectedItem' in changes) { if ('selectedItem' in changes) {
setSelectedItem(changes.selectedItem); setSelectedItem(changes.selectedItem);
} }
...@@ -506,6 +509,7 @@ export function MultiAutocomplete({ ...@@ -506,6 +509,7 @@ export function MultiAutocomplete({
return ( return (
<Autocomplete <Autocomplete
{...props} {...props}
isMulti
value={null} value={null}
suggestions={suggestions.filter( suggestions={suggestions.filter(
item => !selectedItems.includes(getItemId(item)), item => !selectedItems.includes(getItemId(item)),
......
---
category: Bugfix
authors: [MatissJanis]
---
Autocomplete: fix multi-autocomplete filtering UX
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment