-
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
Writing flow: select next block on Enter key #63484
base: trunk
Are you sure you want to change the base?
Conversation
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +374 B (+0.02%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
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.
This was added, I think by me, as an accessibility enhancement. Please provide clear testing instructions so someone can check the new flow. Currently, I am unsure how to test this. Thanks. |
Here's how I tested this. First ensure your "Pages" template has a Title and/or Featured image block after, then a Content block:
Then:
Focus should then be on the next block in the sequence, i.e. if the title block is followed by a featured image, the featured image block should be focused. The purpose is to improve the base writing flow when writing/editing pages in the full-template preview of the site editor. |
e99bfba
to
d35ec89
Compare
cb2bc50
to
1aca4b5
Compare
@@ -15,6 +16,115 @@ import { store as blockEditorStore } from '../../store'; | |||
import { useBlockEditContext } from '../block-edit'; | |||
import { getMultilineTag } from './utils'; | |||
|
|||
function useEnterRef( props ) { |
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.
Nothing in this whole file has changed, except moving from an onKeyDown
React listener to a native DOM one, so that we run it before the default rich text Enter handler.
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.
It's worth noting that we were actually not using the window listener until a couple of months ago, so it reverts some logic of #54543.
I meant to avoid moving focus when calling |
What?
Fixes #54984.
Whenever a default block cannot be inserted on Enter, select the next block.
The next block means:
Why?
Enter does not do anything useful when a template is locked and no default block can be inserter after the block.
How?
This ended up being a slightly larger refactor.
Testing Instructions
Testing Instructions for Keyboard
In the Site Editor, select the post title. Enter should select the next block, and so on. Generally anytime a block is selected and no default block can be inserted, Enter should select the next block.
Screenshots or screencast