From 67261ac463f741292d437b788f0cd0d5e2358abb Mon Sep 17 00:00:00 2001 From: Theodore Kruczek Date: Fri, 29 Dec 2023 18:27:01 -0500 Subject: [PATCH] fix: :bug: fix searchbox looking for dataset on span --- src/hud/SearchBox.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/hud/SearchBox.ts b/src/hud/SearchBox.ts index 4976e56..b3e0fce 100644 --- a/src/hud/SearchBox.ts +++ b/src/hud/SearchBox.ts @@ -215,12 +215,19 @@ function registerListeners () { if (!searchResultsElem) { return; } - searchResultsElem.addEventListener('click', (event: any) => { - const target = event.target; - const satId = target.dataset.satId; + searchResultsElem.addEventListener('click', (event: Event) => { + let target = event.target as HTMLElement; + if (target.className !== 'search-result') { + target = target.closest('.search-result') as HTMLElement; + } + if (!target) { + return; + } + + const satId = target?.dataset.satId as string; clearHover(); - viewer.setSelectedSatellite(satId); + viewer.setSelectedSatellite(parseInt(satId)); }); document.querySelector('#search')?.addEventListener('input', () => {