[fix] comma keyboard shortcuts (#1675)

This PR fixes some issues in our `useDocumentEvents`. It closes
https://github.com/tldraw/tldraw/issues/1667 (I think).

### Change Type

- [x] `patch`

### Release Notes

- [@tldraw/editor] Bug fixes on document events.
This commit is contained in:
Steve Ruiz 2023-06-29 21:30:33 +01:00 committed by GitHub
parent cf2cc8c970
commit c524cac3f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -240,13 +240,14 @@ export function useDocumentEvents() {
container.addEventListener('touchstart', handleTouchStart, { passive: false }) container.addEventListener('touchstart', handleTouchStart, { passive: false })
document.addEventListener('wheel', handleWheel, { passive: false }) container.addEventListener('wheel', handleWheel, { passive: false })
document.addEventListener('gesturestart', preventDefault) document.addEventListener('gesturestart', preventDefault)
document.addEventListener('gesturechange', preventDefault) document.addEventListener('gesturechange', preventDefault)
document.addEventListener('gestureend', preventDefault) document.addEventListener('gestureend', preventDefault)
document.addEventListener('keydown', handleKeyDown) container.addEventListener('keydown', handleKeyDown)
document.addEventListener('keyup', handleKeyUp) container.addEventListener('keyup', handleKeyUp)
window.addEventListener('blur', handleBlur) window.addEventListener('blur', handleBlur)
window.addEventListener('focus', handleFocus) window.addEventListener('focus', handleFocus)
@ -254,13 +255,14 @@ export function useDocumentEvents() {
return () => { return () => {
container.removeEventListener('touchstart', handleTouchStart) container.removeEventListener('touchstart', handleTouchStart)
document.removeEventListener('wheel', handleWheel) container.removeEventListener('wheel', handleWheel)
document.removeEventListener('gesturestart', preventDefault) document.removeEventListener('gesturestart', preventDefault)
document.removeEventListener('gesturechange', preventDefault) document.removeEventListener('gesturechange', preventDefault)
document.removeEventListener('gestureend', preventDefault) document.removeEventListener('gestureend', preventDefault)
document.removeEventListener('keydown', handleKeyDown) container.removeEventListener('keydown', handleKeyDown)
document.removeEventListener('keyup', handleKeyUp) container.removeEventListener('keyup', handleKeyUp)
window.removeEventListener('blur', handleBlur) window.removeEventListener('blur', handleBlur)
window.removeEventListener('focus', handleFocus) window.removeEventListener('focus', handleFocus)