-
-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Description
isInputElement() in manager.utils.ts does not recognize elements with contenteditable="plaintext-only" as input elements, causing hotkeys with ignoreInputs: true (the default for single keys like Backspace, Delete, etc.) to fire when the user is typing in such elements.
Reproduction
- Register a single-key hotkey (e.g.
Backspace) with default options (ignoreInputsdefaults totrue) - Focus a
<div contenteditable="plaintext-only">element - Press Backspace — the hotkey handler fires unexpectedly, in addition to the normal text editing behavior
Root Cause
The isInputElement function checks contentEditable property against 'true' and '', but not against 'plaintext-only':
// packages/hotkeys/src/manager.utils.ts
if (element instanceof HTMLElement) {
const contentEditable = element.contentEditable
if (contentEditable === 'true' || contentEditable === '') {
return true
}
}The contenteditable="plaintext-only" attribute causes the DOM property element.contentEditable to return "plaintext-only", which doesn't match either check.
Suggested Fix
Use element.isContentEditable (a computed boolean that returns true for all editable states including plaintext-only and inherited contenteditable):
if (element instanceof HTMLElement && element.isContentEditable) {
return true
}This would also cover the edge case of inherited contenteditable (where element.contentEditable === "inherit" but element.isContentEditable === true).
Context
contenteditable="plaintext-only" is a valid HTML attribute value supported in all modern browsers. It's increasingly common in rich text editors and custom input components that want plain-text editing without formatting.