Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevents delete key from undoing automatic changes #60858

Merged

Conversation

mhkuu
Copy link
Contributor

@mhkuu mhkuu commented Apr 18, 2024

Created during Yoast Contributor Day on Thursday 18 April 2024.

What?

This PR prevents the delete key (del) from undoing automatic changes, for example through transforms based on prefixes.

Why?

As per #35388, after an automatic transformation from one block to the other, we want the delete key to have the standard behaviour: deleting the character after the caret.

How?

This PR removes the delete button from the list of characters that undoes an automatic change, leaving the backspace and the escape button. Note that with this PR, next to automatic transforms through prefixes (e.g. > to quote, - to list), also other actions regarded as automatic changes will no longer be undoable through the delete button (which I think makes sense).

Testing Instructions

To confirm the behaviour for the delete button:

  1. Create a new post.
  2. Insert some text in a paragraph block.
  3. Prepend > to the text.
  4. Confirm that the paragraph block transforms into a quote block.
  5. Press the delete button (del, or fn + backspace on Mac).
  6. Confirm that the character after the caret is removed.

To confirm the behaviour for the backspace/escape button:

  1. Create a new post.
  2. Insert some text in a paragraph block.
  3. Prepend > to the text.
  4. Confirm that the paragraph block transforms into a quote block.
  5. Press the backspace button.
  6. Confirm that the block transformation is undone.

Testing Instructions for Keyboard

In a new post:

  1. Insert some text (e.g. type Hello World).
  2. Move the caret to the beginning of the text (by using the left arrow, or a keyboard shortcut like <-).
  3. Type > .
  4. Type del.
  5. Confirm that the character after the caret is removed.

Screenshots or screencast

See the bug report for a screencast.

Fixes #35388

@mhkuu mhkuu marked this pull request as ready for review April 18, 2024 13:09
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: mhkuu <mhkuu@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: tomalec <tomalec@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Member

@ellatrix ellatrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure this makes sense

@ellatrix ellatrix added the [Type] Bug An existing feature does not function as intended label Apr 19, 2024
@ellatrix ellatrix merged commit 9912c11 into WordPress:trunk Apr 19, 2024
64 of 68 checks passed
@github-actions github-actions bot added this to the Gutenberg 18.2 milestone Apr 19, 2024
@mhkuu mhkuu deleted the fix/do-not-undo-automatic-change-on-delete branch April 19, 2024 09:52
@colorful-tones colorful-tones added the [Package] Block editor /packages/block-editor label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Block editor /packages/block-editor [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delete at the beginning of newly created quote deletes the quote, not the first charater.
3 participants