diff --git a/.changeset/hungry-donkeys-allow.md b/.changeset/hungry-donkeys-allow.md new file mode 100644 index 00000000..bec576ed --- /dev/null +++ b/.changeset/hungry-donkeys-allow.md @@ -0,0 +1,5 @@ +--- +'@tanstack/devtools': patch +--- + +Ignore the hotkey while focus is in an editable element by guarding the createShortcut callback diff --git a/packages/devtools/src/devtools.tsx b/packages/devtools/src/devtools.tsx index 5a68a04d..f87eb6ec 100644 --- a/packages/devtools/src/devtools.tsx +++ b/packages/devtools/src/devtools.tsx @@ -165,10 +165,21 @@ export default function DevTools() { } }) createEffect(() => { + const isEditableTarget = (element: Element | null) => { + if (!element || !(element instanceof HTMLElement)) return false + if (element.isContentEditable) return true + const tagName = element.tagName + if (tagName === 'INPUT' || tagName === 'TEXTAREA' || tagName === 'SELECT') { + return true + } + return element.getAttribute('role') === 'textbox' + } + const permutations = getHotkeyPermutations(settings().openHotkey) for (const permutation of permutations) { createShortcut(permutation, () => { + if (isEditableTarget(document.activeElement)) return toggleOpen() }) }