@sanity/ui
Advanced tools
Comparing version 2.10.5 to 2.10.6
{ | ||
"name": "@sanity/ui", | ||
"version": "2.10.5", | ||
"version": "2.10.6", | ||
"keywords": [ | ||
@@ -128,3 +128,3 @@ "sanity", | ||
"@sanity/semantic-release-preset": "^5.0.0", | ||
"@sanity/ui-workshop": "^2.0.16", | ||
"@sanity/ui-workshop": "^2.0.18", | ||
"@storybook/addon-a11y": "^8.4.7", | ||
@@ -131,0 +131,0 @@ "@storybook/addon-docs": "^8.4.7", |
import {useEffect} from 'react' | ||
import {useEffectEvent} from 'use-effect-event' | ||
@@ -7,7 +8,11 @@ /** | ||
export function useGlobalKeyDown(onKeyDown: (event: KeyboardEvent) => void): void { | ||
return useEffect(() => { | ||
addEventListener('keydown', onKeyDown) | ||
const handleKeyDown = useEffectEvent((event: KeyboardEvent) => onKeyDown(event)) | ||
return () => removeEventListener('keydown', onKeyDown) | ||
}, [onKeyDown]) | ||
useEffect(() => { | ||
const handler = (event: KeyboardEvent) => handleKeyDown(event) | ||
window.addEventListener('keydown', handler) | ||
return () => window.removeEventListener('keydown', handler) | ||
}, [handleKeyDown]) | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
5509375
71316