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

:bug: (autocomplete) fix multi-autocomplete causing crashes (#2207)

parent e792afb1
No related branches found
No related tags found
No related merge requests found
......@@ -31,16 +31,12 @@ function findItem<T extends Item>(
strict: boolean,
suggestions: T[],
value: T | T['id'],
): T | null {
): T | T['id'] | null {
if (strict) {
const idx = suggestions.findIndex(item => item.id === value);
return idx === -1 ? null : suggestions[idx];
}
if (typeof value === 'string') {
throw new Error('value can be string only if strict = false');
}
return value;
}
......@@ -302,7 +298,7 @@ function SingleAutocomplete<T extends Item>({
}
}}
highlightedIndex={highlightedIndex}
selectedItem={selectedItem || null}
selectedItem={selectedItem instanceof Object ? selectedItem : null}
itemToString={itemToString}
inputValue={value}
isOpen={isOpen}
......
---
category: Bugfix
authors: [MatissJanis]
---
Fix multi-autocomplete in rules page causing crashes
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