WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.4k stars 4.16k forks source link

Cmd [arrow] commands do not function as expected #5805

Open markjaquith opened 6 years ago

markjaquith commented 6 years ago

Issue Overview

In macOS, ⌘ [arrow] commands have well-defined meanings, in a text-editing context.

In Gutenberg, these commands inconsistently navigate your caret between blocks.

Expected Behavior

macOS default behavior.

afercia commented 6 years ago

Question:

Should a single block (e.g. a paragraph) define an arrow-behavior context? Currently, a single paragraph in Gutenberg is equivalent to a textarea and communicated as such to assistive technologies. Thus, I'd expect arrow commands to work within a single block.

Or, should the whole post be the context for the arrows commands?

afercia commented 6 years ago

Also, worth considering the equivalent arrow commands on Windows.

mtias commented 5 years ago

@mcsf I believe many of these work a lot better now, can you check on the status and see if anything remains to be improved and how pressing it is?

mcsf commented 5 years ago

Somewhat related: #4004

can you check on the status and see if anything remains to be improved and how pressing it is?

I don't think this was ever explicitly implemented in WritingFlow, so what we're seeing ends up being a combination of native behaviour (e.g. jumping to the start or end of a block's text field) with editor behaviour (navigating between blocks when the caret sits at a block boundary).

It could be implemented, but this would be a new task, not a fix.

mtias commented 5 years ago

I've noticed a lot of these interactions being better (moving to the end / beginning of the block, etc), hence the question. It'd be nice to validate a few more and look at implementing missing ones if it can be done reliably across browsers.

designsimply commented 5 years ago

I tested using the demo post with WordPress 4.9.8 and Gutenberg 4.3 using Firefox 63.0.1, Chrome 70.0.3538.77, and Safari 12.0 on macOS 10.13.6 and found the following to be generally true.

When the caret is not at a block boundary:

If the caret is sitting at a block boundary:

Assuming block boundaries are defined as:

Exceptions:

This is what I found after auditing the demo post which contains the following blocks:

designsimply commented 5 years ago

I propose closing this issue after creating separate issues for the following exceptions noted above:

  1. Firefox ⌘ ← and ⌘ → block boundary movements (low priority)
  2. Empty captions
  3. Button block

@mtias @mcsf does that sound good to you?

Or do all blocks need to be audited? (list of blocks)

waterplea commented 5 years ago

On Windows you can navigate by word with Ctrl + Arrow keys. In Gutenberg this doesn't work (although works in case of selection by word with Ctrl + Shift + Arrow keys). To be honest, this is SO basic and SO needed that I'm surprised this was not marked as critical and the editor was released with this bug. You basically cannot edit text with keyboard because anyone who has any speed in text writing uses this all the time.

afercia commented 5 years ago

@waterplea thanks for your feedback. I'd totally agree testing on Windows would need some more care. Also totally agree basic operations like navigating and selecting text with the keyboard should work flawlessly and should be tested in a solid way.

The specific bug you've mentioned has been recently reported in https://github.com/WordPress/gutenberg/issues/14170 and fixed in https://github.com/WordPress/gutenberg/pull/14184. The fix will be included in the next release.

paaljoachim commented 3 years ago

Can we get a status update? Thank you!

mtias commented 2 years ago

@ellatrix I've been thinking that for the ⌘ ↑ case, the first press works fine (moves to the top of the current block) but we should make it so the subsequent press moves to the top of the previous block. What do you think?

ellatrix commented 2 years ago

@mtias Maybe. I think that behaviour may make more sense for Alt+Arrow?

mtias commented 2 years ago

Would command+arrow then move to the start of the document? I think the issue now is that once on a block boundary, command+Arrow feels erratic.

ellatrix commented 2 years ago

Yes, Cmd+Arrow should move to the start of the document then, Alt+Arrow block by block.

ellatrix commented 3 months ago

I think this works mostly correctly now:

Cmd + horizontal arrow sets the caret at the start or end of the line. Cmd + vertical arrow sets the caret at the start or end of the focussed input/rich text element.

But it won't let you move the caret to the first or last block. One idea could be to make it similar to how Cmd+A works:

I could enhance Cmd + arrow similarly so it first move to the start of the input, then the first block from the nested blocks, then the first block of the parent nested blocks, and so on.

But it seems the main issue is fixed here, it depends what "beginning of your content" means (in the post and site editor).