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

Blocks: Select the previous block when clicking backspace #683

Merged
merged 4 commits into from
May 8, 2017

Conversation

youknowriad
Copy link
Contributor

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)

@youknowriad youknowriad added the [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). label May 5, 2017
@youknowriad youknowriad self-assigned this May 5, 2017
@jasmussen
Copy link
Contributor

Works really well. I dig this interaction! 👍

@aduth
Copy link
Member

aduth commented May 5, 2017

I pushed some adjustments, mainly in that if Editable's focus prop changes from true to false, it seems sensible that it blurs itself. With this I found we didn't need as much of the componentDidUpdate logic in block.js. In my testing this doesn't seem to interfere with Editable's assuming focus automatically when clicking the block.

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.

! prevProps.focus &&
(
! document.activeElement ||
document.activeElement.closest( '.editor-visual-editor__block' ) !== this.node
Copy link
Member

@aduth aduth May 5, 2017

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

@youknowriad
Copy link
Contributor Author

youknowriad commented May 8, 2017

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?

I think this is a good thing. I added this interaction in 0d71661. How does that feel?

@jasmussen
Copy link
Contributor

I think this is a good thing. I added this interaction in 5987b97. How does that feel?

Feels really really good. 👍

@youknowriad youknowriad merged commit 37d37cc into master May 8, 2017
@youknowriad youknowriad deleted the polish/select-previous-on-backspace branch May 8, 2017 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants