fix(search): use Symbol key for searchInitialized to avoid collisions
This commit is contained in:
@@ -7,7 +7,8 @@ type QuickSearchResult = {
|
|||||||
type?: string
|
type?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const globalWindow = window as Window & { searchInitialized?: boolean }
|
const searchInitializedKey = Symbol('searchInitialized')
|
||||||
|
const globalWindow = window as Window & { [searchInitializedKey]?: boolean }
|
||||||
|
|
||||||
let searchTimeout: number | undefined
|
let searchTimeout: number | undefined
|
||||||
const searchInput = document.getElementById('search-input') as HTMLInputElement | null
|
const searchInput = document.getElementById('search-input') as HTMLInputElement | null
|
||||||
@@ -150,10 +151,10 @@ const onDocumentClick = (event: MouseEvent): void => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const initQuickSearch = (): void => {
|
const initQuickSearch = (): void => {
|
||||||
if (globalWindow.searchInitialized) {
|
if (globalWindow[searchInitializedKey]) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
globalWindow.searchInitialized = true
|
globalWindow[searchInitializedKey] = true
|
||||||
|
|
||||||
if (!searchInput || !searchDropdown) {
|
if (!searchInput || !searchDropdown) {
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user