From 9ac4a0fbd2a4d0976226507bf4651da67493b626 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Mon, 19 Dec 2022 16:22:29 +0100 Subject: [PATCH] fix(core): input focus preventing selection rect Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> --- packages/core/src/composables/useKeyPress.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/core/src/composables/useKeyPress.ts b/packages/core/src/composables/useKeyPress.ts index 3cd41631..21534760 100644 --- a/packages/core/src/composables/useKeyPress.ts +++ b/packages/core/src/composables/useKeyPress.ts @@ -3,10 +3,16 @@ import type { KeyFilter, MaybeRef } from '@vueuse/core' import { isBoolean, isFunction } from '@vueuse/core' function isInputDOMNode(event: KeyboardEvent): boolean { - const target = event.composedPath()[0] as HTMLElement + const target = (event.composedPath?.()?.[0] || event.target) as HTMLElement + + // we want to be able to do a multi selection event if we are in an input field + if (event.ctrlKey || event.metaKey || event.shiftKey) return false + const hasAttribute = isFunction(target.hasAttribute) ? target.hasAttribute('contenteditable') : false + const closest = isFunction(target.closest) ? target.closest('.nokey') : null + // when an input field is focused we don't want to trigger deletion or movement of nodes return ['INPUT', 'SELECT', 'TEXTAREA'].includes(target?.nodeName) || hasAttribute || !!closest }