diff --git a/src/hooks/useKeyPress.ts b/src/hooks/useKeyPress.ts index 8ac7dcf8..6b164556 100644 --- a/src/hooks/useKeyPress.ts +++ b/src/hooks/useKeyPress.ts @@ -108,7 +108,8 @@ function useKeyOrCode(eventCode: string, keysToWatch: KeyCode): KeyOrCode { } function isInputDOMNode(event: KeyboardEvent): boolean { - const target = event.composedPath()[0] as HTMLElement; + // using composed path for handling shadow dom + const target = (event.composedPath?.()[0] || event.target) as HTMLElement; return ['INPUT', 'SELECT', 'TEXTAREA'].includes(target?.nodeName) || target?.hasAttribute('contenteditable'); }