Skip to content

Undo / redo (keyboard shortcuts) affecting the whole document rather than the focussed TextControl #18755

@rmorse

Description

@rmorse

Describe the bug
When using the TextControl component, pressing ctrl+z is expected to undo what you've written inside the component, and this works in most scenarios such as the sidebar.

What I've noticed is that a TextControl generated from within the editor never gets these keyboard events passed down it - so pressing ctrl+z results in the editors undo state being modified, while the current TextControl I'm using doesn't get affected at all. This is occuring for my TextControls in Popovers + Modals, as well as reproducible with built in components.

To reproduce

  1. In a block, type some text, and create a link from it
  2. Enter a URL in the inline popup UI
  3. Before submitting, press ctrl-z
  4. Notice the document performs an undo, and the current focussed TextControl does nothing (if you've just started a new document, the whole thing disseapears, but if you have multiple undo levels before you created the link, you will see it step through them)
  5. Right clicking inside the URL TextControl, shows the browser undo/redo and they work as expected

Expected behavior
Pressing ctrl-z or ctrl-y inside a TextControl should allow for the native browser implementation of undo/redo within a text input field, and the document should not go back an undo level.

Screenshots
gutenberg-undo-issue

Desktop:

  • Windows 10
  • Chrome, Edge, Firefox

Additional context

  • Gutenberg v6.9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] HistoryHistory, undo, redo, revisions, autosave.[Feature] Link EditingLink components (LinkControl, URLInput) and integrations (RichText link formatting)[Type] BugAn existing feature does not function as intended

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions