From 4b92f07f4ba732cd02f8ffe0958fb77b3d5984c6 Mon Sep 17 00:00:00 2001 From: Matiss Janis Aboltins Date: Tue, 9 Jan 2024 19:01:21 +0000 Subject: [PATCH 1/2] :bug: (autocomplete) fix multi-autocomplete causing crashes Closes #2187 --- .../src/components/autocomplete/Autocomplete.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx b/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx index aa10a321826..10483817b1f 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( 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({ } }} highlightedIndex={highlightedIndex} - selectedItem={selectedItem || null} + selectedItem={selectedItem instanceof Object ? selectedItem : null} itemToString={itemToString} inputValue={value} isOpen={isOpen} From e46350f3aef77353a3199ff4848e0f38ded982d4 Mon Sep 17 00:00:00 2001 From: Matiss Janis Aboltins Date: Tue, 9 Jan 2024 19:02:13 +0000 Subject: [PATCH 2/2] Release notes --- upcoming-release-notes/2207.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 upcoming-release-notes/2207.md diff --git a/upcoming-release-notes/2207.md b/upcoming-release-notes/2207.md new file mode 100644 index 00000000000..4db717c4aed --- /dev/null +++ b/upcoming-release-notes/2207.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [MatissJanis] +--- + +Fix multi-autocomplete in rules page causing crashes