From 468699bfdd0c1890926c75775e6f5e64132ac74e Mon Sep 17 00:00:00 2001 From: CRIMX Date: Mon, 9 Dec 2024 19:08:49 +0800 Subject: [PATCH 1/2] fix(system): safely handles non-html-element object `event.composedPath` and `event.target` do not always return `HTMLElement` object(as their types suggested). --- packages/system/src/utils/dom.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/system/src/utils/dom.ts b/packages/system/src/utils/dom.ts index 886547725..b3648ede3 100644 --- a/packages/system/src/utils/dom.ts +++ b/packages/system/src/utils/dom.ts @@ -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'); From d60331e6baa7931c46af219e35c1bedbd156187c Mon Sep 17 00:00:00 2001 From: moklick Date: Mon, 9 Dec 2024 17:36:18 +0100 Subject: [PATCH 2/2] chore(changeseg): add --- .changeset/brown-pugs-pump.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/brown-pugs-pump.md diff --git a/.changeset/brown-pugs-pump.md b/.changeset/brown-pugs-pump.md new file mode 100644 index 000000000..4c62f5513 --- /dev/null +++ b/.changeset/brown-pugs-pump.md @@ -0,0 +1,5 @@ +--- +'@xyflow/system': patch +--- + +Refactor isInputDOMNode so that it handles non-html objects