Skip to content

Commit

Permalink
Merge pull request xyflow#4874 from crimx/patch-1
Browse files Browse the repository at this point in the history
fix(system): safely handles non-html-element object
  • Loading branch information
moklick authored Dec 9, 2024
2 parents 21b7e95 + d60331e commit 90d4726
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/brown-pugs-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@xyflow/system': patch
---

Refactor isInputDOMNode so that it handles non-html objects
2 changes: 1 addition & 1 deletion packages/system/src/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const inputTags = ['INPUT', 'SELECT', 'TEXTAREA'];
export function isInputDOMNode(event: KeyboardEvent): boolean {
// using composed path for handling shadow dom
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
return isInput || !!target?.closest('.nokey');
Expand Down

0 comments on commit 90d4726

Please sign in to comment.