-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: implement Alt+Arrow #44081
Conversation
Size Change: +24 B (0%) Total Size: 1.26 MB
ℹ️ View Unchanged
|
packages/block-editor/src/components/writing-flow/use-arrow-nav.js
Outdated
Show resolved
Hide resolved
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.
Nice. :) (Do you know what's up with the tests?)
@@ -956,6 +956,49 @@ test.describe( 'Writing Flow', () => { | |||
page.locator( 'role=document[name="Paragraph block"i]' ) | |||
).toHaveText( /^a+\.a$/ ); | |||
} ); | |||
|
|||
test( 'should vertically move the caret when pressing Alt', async ( { |
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.
These tests are providing a pretty good self-documentation of text interactions
I'm not sure why the added test is failing here but not locally. I'll have to remove some parts. |
ad9197c
to
313ca77
Compare
I removed the testing of native behaviour for now so we can get this merged. |
This is a cool one, thanks! |
What?
Implements Alt+Arrow in writing flow. Currently the caret is placed as if Alt weren't pressed, at the closest edge of the next tabbable element. Instead, the caret should be placed at the furthest edge and also at the furthest horizontal position.
Why?
As a result, you can quickly press Alt+Arrow Up/Down to navigate blocks of text. This emulates Alt+Arrow Up/Down in normal text editors, where it normally navigates to the previous/next line break or text block.
How?
Changes the arguments passed to
placeCaretAtVerticalEdge
.I didn't add behaviour to also stop at line breaks, as this is a bit more challenging. This change on its own should already be a huge improvement.
Testing Instructions
Screenshots or screencast