From af97972366a5a7f5d47343a6e23198ffffc728c6 Mon Sep 17 00:00:00 2001 From: Chen Fengyuan Date: Sun, 18 Aug 2024 16:05:33 +0800 Subject: [PATCH] fix(element-selection): disable keyboard control when input something fix #1192 --- packages/element-selection/src/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/element-selection/src/index.ts b/packages/element-selection/src/index.ts index 237022db..ed0c229b 100644 --- a/packages/element-selection/src/index.ts +++ b/packages/element-selection/src/index.ts @@ -501,6 +501,16 @@ export default class CropperSelection extends CropperElement { return; } + const { activeElement } = document; + + // Disable keyboard control when input something + if (activeElement && ( + ['INPUT', 'TEXTAREA'].includes(activeElement.tagName) + || ['true', 'plaintext-only'].includes((activeElement as HTMLElement).contentEditable) + )) { + return; + } + switch ((event as KeyboardEvent).key) { case 'Backspace': if ((event as KeyboardEvent).metaKey) {