From 7e9fb5df5e9abd51cef35cb21a879427a67f4beb Mon Sep 17 00:00:00 2001 From: Pranay Pandey <79053599+Pranay-Pandey@users.noreply.github.com> Date: Wed, 23 Oct 2024 18:21:17 +0530 Subject: [PATCH] fix(web): Add debouncing to the search popup form (#13684) This will fix the bug where when we click on the second date picker just after selecting date in first date picker it closes the search popup form --- .../search-bar/search-bar.svelte | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/web/src/lib/components/shared-components/search-bar/search-bar.svelte b/web/src/lib/components/shared-components/search-bar/search-bar.svelte index b0bbdbe71f..67c3cfe757 100644 --- a/web/src/lib/components/shared-components/search-bar/search-bar.svelte +++ b/web/src/lib/components/shared-components/search-bar/search-bar.svelte @@ -66,13 +66,17 @@ }; const onFocusOut = () => { - if ($isSearchEnabled) { - $preventRaceConditionSearchBar = true; - } + const focusOutTimer = setTimeout(() => { + if ($isSearchEnabled) { + $preventRaceConditionSearchBar = true; + } - closeDropdown(); - $isSearchEnabled = false; - showFilter = false; + closeDropdown(); + $isSearchEnabled = false; + showFilter = false; + }, 100); + + clearTimeout(focusOutTimer); }; const onHistoryTermClick = async (searchTerm: string) => {