Skip to content

Commit

Permalink
fix: should search immediately by pressing any key (reported by @alon91)
Browse files Browse the repository at this point in the history
this closes #465
  • Loading branch information
foray1010 committed May 17, 2019
1 parent 5aaf753 commit f0fb879
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/js/popup/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ const SearchContainer = ({getSearchResult, isFocusSearchInput, setIsFocusSearchI
getSearchResult(inputValue)
}, [getSearchResult, inputValue])

const handleSingleKeyPress = React.useCallback(() => {
const notFocusOnInputElement =
!document.activeElement || !['INPUT', 'TEXTAREA'].includes(document.activeElement.tagName)
if (notFocusOnInputElement) {
setIsFocusSearchInput(true)
}
}, [setIsFocusSearchInput])
const handleSingleKeyPress = React.useCallback(
(evt: KeyboardEvent) => {
const notFocusOnInputElement =
!document.activeElement || !['INPUT', 'TEXTAREA'].includes(document.activeElement.tagName)
if (notFocusOnInputElement) {
setInputValue(evt.key)
setIsFocusSearchInput(true)
}
},
[setIsFocusSearchInput]
)
useKeyBindingsEvent({key: /^.$/, windowId: BASE_WINDOW}, handleSingleKeyPress)

const handleBlur = React.useCallback(() => {
Expand Down

0 comments on commit f0fb879

Please sign in to comment.