From d8ae6bd9a2ceb7ab809c1b219d9fd905dbb8bc37 Mon Sep 17 00:00:00 2001 From: moklick Date: Wed, 7 Oct 2020 17:40:35 +0200 Subject: [PATCH] refactor(remove-nodes): check if target has contenteditable attr closes #560 --- src/utils/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index 95130e1e..caffa530 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -2,8 +2,11 @@ import { DraggableEvent } from 'react-draggable'; import { MouseEvent as ReactMouseEvent } from 'react'; export const isInputDOMNode = (e: ReactMouseEvent | DraggableEvent | KeyboardEvent) => { - const target = e.target as HTMLElement; - return e && target && ['INPUT', 'SELECT', 'TEXTAREA', 'BUTTON'].includes(target.nodeName); + const target = e?.target as HTMLElement; + + return ( + ['INPUT', 'SELECT', 'TEXTAREA', 'BUTTON'].includes(target?.nodeName) || target?.hasAttribute('contenteditable') + ); }; export const getDimensions = (node: HTMLDivElement) => ({