Merge pull request #2838 from wbkd/refactor/use-key-press
refactor(use-key-press): handle modifier keys + inputs
This commit is contained in:
5
.changeset/witty-eagles-type.md
Normal file
5
.changeset/witty-eagles-type.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@reactflow/core': patch
|
||||
---
|
||||
|
||||
refactor: use key press handle modifier keys + input
|
||||
@@ -103,17 +103,12 @@ export function isInputDOMNode(event: KeyboardEvent | ReactKeyboardEvent): boole
|
||||
// using composed path for handling shadow dom
|
||||
const target = (kbEvent.composedPath?.()?.[0] || event.target) as HTMLElement;
|
||||
|
||||
const isInput = ['INPUT', 'SELECT', 'TEXTAREA'].includes(target?.nodeName) || target?.hasAttribute('contenteditable');
|
||||
// we want to be able to do a multi selection event if we are in an input field
|
||||
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
||||
return false;
|
||||
}
|
||||
const isModifierKey = event.ctrlKey || event.metaKey || event.shiftKey;
|
||||
|
||||
// when an input field is focused we don't want to trigger deletion or movement of nodes
|
||||
return (
|
||||
['INPUT', 'SELECT', 'TEXTAREA'].includes(target?.nodeName) ||
|
||||
target?.hasAttribute('contenteditable') ||
|
||||
!!target?.closest('.nokey')
|
||||
);
|
||||
return (isInput && !isModifierKey) || !!target?.closest('.nokey');
|
||||
}
|
||||
|
||||
export const isMouseEvent = (
|
||||
|
||||
Reference in New Issue
Block a user