-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Blocks: Select the previous block when clicking backspace #683
Conversation
Works really well. I dig this interaction! 👍 |
I pushed some adjustments, mainly in that if Editable's If these changes make sense to you, feel free to merge 👍 Separately, I think another adjustment we should do is consider what happens after backspace deletes the block. Should we move focus to the previous block? We should consider the case someone wants to hold backspace to remove all content from their post. |
editor/modes/visual-editor/block.js
Outdated
! prevProps.focus && | ||
( | ||
! document.activeElement || | ||
document.activeElement.closest( '.editor-visual-editor__block' ) !== this.node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic no longer exists, but this could have been expressed more simply as:
! this.node.contains( document.activeElement )
https://developer.mozilla.org/en-US/docs/Web/API/Node/contains
I think this is a good thing. I added this interaction in 0d71661. How does that feel? |
Feels really really good. 👍 |
This solves the second part of #666
When we hit backspace and we can't merge the block with the previous one, we select the previous one to be able to hit backspace a second time and delete it.
You can currently test it with the
separator
block followed by a text block (the image and the embed block have small focus issues right now, but there are open PRs to fix those)