Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/popup.search/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ const el = document.getElementById('textInput') as HTMLInputElement

el?.focus()

for (let i = 0; i <= 1000; i += 100) {
setTimeout(() => {
el?.focus()
}, i)
}

el?.addEventListener('blur', () => {
if (Windows.id !== undefined) IPC.sendToSidebar(Windows.id, 'onOutsideSearchExit')
})
Expand Down Expand Up @@ -92,6 +98,7 @@ void (async () => {
IPC.setInstanceType(InstanceType.search)
IPC.setupGlobalMessageListener()
IPC.registerActions({ closePopup })

const [win] = await Promise.all([
browser.windows.getCurrent({ populate: false }),
Settings.loadSettings(),
Expand Down
14 changes: 4 additions & 10 deletions src/services/search.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,17 @@ import { Windows } from './windows'
import { History } from './history'
import { Bookmarks } from './bookmarks'
import * as Selection from './selection'

export const INPUT_TIMEOUT = 300

export function init(): void {
if (Settings.state.searchBarMode === 'static') Search.reactive.barIsShowed = true
}

let inputTimeout: number | undefined
export function onOutsideSearchInput(value: string): void {
if (!Windows.focused) return
if (!Search.reactive.barIsShowed && Search.rawValue) Search.toggleBar()

Search.reactive.rawValue = Search.rawValue = value

clearTimeout(inputTimeout)
inputTimeout = setTimeout(() => {
Search.search(Search.rawValue)
}, INPUT_TIMEOUT)
Search.search(Search.rawValue)
}

export function onOutsideSearchExit(): void {
Expand Down Expand Up @@ -441,8 +434,9 @@ export function start(): void {
// Reset browser action
setTimeout(() => browser.browserAction.setPopup({ popup: null }), 500)
}

showBar()
else {
showBar()
}
}

export function close(): void {
Expand Down