diff --git a/src/components/treemode/TreeMode.svelte b/src/components/treemode/TreeMode.svelte index d8dd541..2c48d4d 100644 --- a/src/components/treemode/TreeMode.svelte +++ b/src/components/treemode/TreeMode.svelte @@ -23,7 +23,7 @@ expandSelection, findRootPath } from '../../logic/selection.js' - import { isContentEditableDiv } from '../../utils/domUtils.js' + import { isContentEditableDiv, isTextInput } from '../../utils/domUtils.js' import { getIn, setIn, @@ -458,7 +458,7 @@ findRootPath function handleKeyDown (event) { const combo = keyComboFromEvent(event) - if (!isContentEditableDiv(event.target)) { + if (!isContentEditableDiv(event.target) && !isTextInput(event.target)) { if (combo === 'Ctrl+X' || combo === 'Command+X') { event.preventDefault() handleCut() diff --git a/src/utils/domUtils.js b/src/utils/domUtils.js index aa8f9e8..c5a9f40 100644 --- a/src/utils/domUtils.js +++ b/src/utils/domUtils.js @@ -188,6 +188,12 @@ export function isContentEditableDiv (element) { return (element.nodeName === 'DIV' && element.contentEditable === 'true') } +// test whether a DOM element is an "input" with type "text" +export function isTextInput (element) { + console.log('element', element) + return (element.nodeName === 'INPUT' && element.type && element.type.toLowerCase() === 'text') +} + function hasAttribute (element, name, value) { return typeof element.getAttribute === 'function' && element.getAttribute(name) === value }