added cleanup function

This commit is contained in:
RockBacon9922 2022-07-08 09:38:44 +01:00
parent 13584d74dd
commit 84c32a4e40

View file

@ -77,6 +77,14 @@ export const TopBar: React.FC<TopBarProps> = (props) => {
searchRef.current.focus()
}
})
return () => {
//remove event listener
document.removeEventListener('keydown', (e) => {
if (e.metaKey && e.key === 'k' && searchRef.current) {
searchRef.current.focus()
}
})
}
},[])
return (