Merge pull request #4874 from crimx/patch-1
fix(system): safely handles non-html-element object
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@xyflow/system': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Refactor isInputDOMNode so that it handles non-html objects
|
||||||
@@ -40,7 +40,7 @@ const inputTags = ['INPUT', 'SELECT', 'TEXTAREA'];
|
|||||||
export function isInputDOMNode(event: KeyboardEvent): boolean {
|
export function isInputDOMNode(event: KeyboardEvent): boolean {
|
||||||
// using composed path for handling shadow dom
|
// using composed path for handling shadow dom
|
||||||
const target = (event.composedPath?.()?.[0] || event.target) as HTMLElement;
|
const target = (event.composedPath?.()?.[0] || event.target) as HTMLElement;
|
||||||
const isInput = inputTags.includes(target?.nodeName) || target?.hasAttribute('contenteditable');
|
const isInput = inputTags.includes(target?.nodeName) || target?.hasAttribute?.('contenteditable');
|
||||||
|
|
||||||
// when an input field is focused we don't want to trigger deletion or movement of nodes
|
// when an input field is focused we don't want to trigger deletion or movement of nodes
|
||||||
return isInput || !!target?.closest('.nokey');
|
return isInput || !!target?.closest('.nokey');
|
||||||
|
|||||||
Reference in New Issue
Block a user