Skip to content

Commit

Permalink
🐛 (autocomplete) fix multi-autocomplete causing crashes (actualbudget…
Browse files Browse the repository at this point in the history
  • Loading branch information
MatissJanis authored Jan 10, 2024
1 parent e792afb commit 3eee0b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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}
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2207.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [MatissJanis]
---

Fix multi-autocomplete in rules page causing crashes

0 comments on commit 3eee0b1

Please sign in to comment.