From 8fe0b97776ade337f9d02e8a3457b0caa7067904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20M=C3=B6ller?= Date: Mon, 1 Aug 2022 18:27:58 +0200 Subject: [PATCH] feat(useKeyPress): add additional check for nokey classname to support custom inputs closes #2254 --- packages/core/src/hooks/useKeyPress.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/core/src/hooks/useKeyPress.ts b/packages/core/src/hooks/useKeyPress.ts index 2e6c65c1..610fc1e1 100644 --- a/packages/core/src/hooks/useKeyPress.ts +++ b/packages/core/src/hooks/useKeyPress.ts @@ -110,5 +110,9 @@ function useKeyOrCode(eventCode: string, keysToWatch: KeyCode): KeyOrCode { function isInputDOMNode(event: KeyboardEvent): boolean { const target = event.target as HTMLElement; - return ['INPUT', 'SELECT', 'TEXTAREA'].includes(target?.nodeName) || target?.hasAttribute('contenteditable'); + return ( + ['INPUT', 'SELECT', 'TEXTAREA'].includes(target?.nodeName) || + target?.hasAttribute('contenteditable') || + !!target?.closest('.nokey') + ); }