Skip to content

A local-first personal finance app

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

Matiss Janis Aboltins3eee0b11d26b
diff --git a/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx b/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx
index aa10a32182..10483817b1 100644
--- a/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx
+++ b/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx
@@ -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}
diff --git a/upcoming-release-notes/2207.md b/upcoming-release-notes/2207.md
new file mode 100644
index 0000000000..4db717c4ae
--- /dev/null
+++ b/upcoming-release-notes/2207.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [MatissJanis]
+---
+
+Fix multi-autocomplete in rules page causing crashes