From d4287ecb0fda873ddb3d8f9830915a4025c28e3d Mon Sep 17 00:00:00 2001 From: Josh Hootman Date: Tue, 2 Jan 2024 09:18:44 -0600 Subject: [PATCH] add clearSelection fn to reset group state Signed-off-by: Josh Hootman --- frontend/src/lib/ComboBox.svelte | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/frontend/src/lib/ComboBox.svelte b/frontend/src/lib/ComboBox.svelte index ade99104..88d4a889 100644 --- a/frontend/src/lib/ComboBox.svelte +++ b/frontend/src/lib/ComboBox.svelte @@ -72,7 +72,7 @@ onMount(async () => { groupContext.subscribe((value) => { - if(value?.name) searchGroups = value.name; + if (value?.name) searchGroups = value.name; }); // Changes the text in the Modal's group field placeholder @@ -213,6 +213,12 @@ rootMargin: '20px', unobserveOnEnter: true }; + + function clearSelection() { + selectedGroup = ''; + searchGroups = ''; + groupContext.set('clear'); + }
@@ -254,7 +260,9 @@ }} on:blur={() => { status = 'blur'; - if (!selectedGroup.name) groupContext.set(); + if (!selectedGroup) { + clearSelection(); + } }} /> @@ -262,11 +270,7 @@