Skip to content

isInputElement does not recognize contenteditable="plaintext-only" #50

@magicismight

Description

@magicismight

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

  1. Register a single-key hotkey (e.g. Backspace) with default options (ignoreInputs defaults to true)
  2. Focus a <div contenteditable="plaintext-only"> element
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions