From 02b189d3af2b99fa5913bf6db71fd5cfe324cab7 Mon Sep 17 00:00:00 2001 From: Gaurav Shandilya Date: Fri, 11 Oct 2024 13:48:12 +0530 Subject: [PATCH] refactor: manage single popover instance Signed-off-by: Gaurav Shandilya --- assets/js/offline-search.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/assets/js/offline-search.js b/assets/js/offline-search.js index d6bec0bf..7644702f 100644 --- a/assets/js/offline-search.js +++ b/assets/js/offline-search.js @@ -61,24 +61,13 @@ // // Dispose existing popover // - - { - let popover = bootstrap.Popover.getInstance($targetSearchInput[0]); - if (popover !== null) { - popover.dispose(); - } - } - + bootstrap.Popover.getInstance($targetSearchInput[0])?.dispose(); // // Search // - - if (idx === null) { - return; - } - const searchQuery = $targetSearchInput.val(); - if (searchQuery === "") { + + if (idx === null || searchQuery === "") { return; }