Skip to content

Commit

Permalink
Persist event in useDoubleClick (#998)
Browse files Browse the repository at this point in the history
Also bind the mousetrap to the document
  • Loading branch information
jameskerr authored Aug 14, 2020
1 parent f20008c commit 2e370ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/js/components/hooks/useDoubleClick.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export default function useDoubleClick(
return () => clearTimeout(singleClickTimer)
}, [clicks])

return (e: MouseEvent) => {
return (e: SyntheticEvent<HTMLElement>) => {
e.persist()
setEvent(e)
setClicks((clicks) => clicks + 1)
}
Expand Down
4 changes: 3 additions & 1 deletion src/js/components/useSearchShortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import Tabs from "../state/Tabs"
export default function() {
let dispatch = useDispatch()
useEffect(() => {
const bindings = new Mousetrap()
const el = document.documentElement
if (!el) throw new Error("No Document Element")
const bindings = new Mousetrap(el)
.bind("mod+t", () => dispatch(Tabs.new()))
.bind("mod+w", (e) => {
e.preventDefault()
Expand Down

0 comments on commit 2e370ab

Please sign in to comment.