Skip to content

Enter on Cancel saves edited text instead of cancelling #424

Open

Description

@nsdeschenes

Problem

While editing an incident title, pressing Enter with Cancel focused saves the draft instead of cancelling. The editor also intercepts qualifying Enter shortcuts on unrelated controls.

This behavior predates the StyleX migration in #408.

Reproduction

  1. Open a test incident and edit its title.
  2. Change the text.
  3. Tab past Save onto Cancel.
  4. Press Enter.

The changed draft is submitted. Expected behavior is to discard the draft without calling onSave.

Verified in a browser using the actual EditableTextField component. Enter on focused Cancel invoked the save callback once. For multiline fields, Ctrl/Cmd+Enter has the same scope problem; plain Enter remains a newline shortcut.

Cause and suggested fix

The document-level keydown listener calls preventDefault() and save() without checking the event target. This suppresses native button activation.

Handle the editor shortcuts on the input and textarea. Let Save, Cancel, and unrelated controls retain their own native keyboard behavior.

Regression coverage should include Cancel in both single-line layouts, an unrelated button activated by Enter, native Save activation, and multiline newline/Ctrl/Cmd+Enter behavior.

History

Identified in this Warden comment. The same listener exists in the pre-migration component and dates to the original component addition.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions