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

Keep caret position / selection when switching Editor mode via the keyboard shortcut #16901

Open
afercia opened this issue Aug 5, 2019 · 1 comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Enhancement A suggestion for improvement.

Comments

@afercia
Copy link
Contributor

afercia commented Aug 5, 2019

#16874 fixed the focus management when switching between "Code Editor" or "Visual Editor" by activating the related items in the More menu.

However, when switching between "Code Editor" or "Visual Editor" using the related keyboard shortcut, there's a focus loss.

On a mac, the shortcut is: Shift Option Cmd M
On Windows, it's: Shift Ctrl Alt M

To reproduce:

  • edit a post that has a few paragraphs
  • either put the caret within, for example, the third paragraph
  • or select a word within the third paragraph
  • switch between Editor modes using the keyboard shortcut
  • see that there's a focus loss

Expecterd:
The caret insertion point or the current selection should be preserved.
If focus was on an element of a Block UI, focus should be restored there (visual) or at the beginning of the block source (code)

Worth noting a similar functionality was introduced a while ago for the Classic Editor. See https://core.trac.wordpress.org/changeset/42184 / https://core.trac.wordpress.org/ticket/42530

It still sort of works when activating the Classic Editor plugin. It appears to not work so well now. Seems to me HTML tags or Gutenberg comments (if any) prevents this feature to work correctly.

Regardless, it's a powerful feature for all keyboard users and saves time while editing a post. I'd like to propose to implement an equivalent feature in Gutenberg too.

It should work only when using the keyboard shortcut.
Instead, when using the related commands in the More menu, the behavior implemented in #16874 seems the most appropriate.

@afercia afercia added [Type] Enhancement A suggestion for improvement. [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [a11y] Keyboard & Focus labels Aug 5, 2019
@diouldebalde
Copy link

thematique

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). [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants