Skip to content

Don't focus the classic editor when switching editor mode by using the keyboard. - #13560

Closed
afercia wants to merge 3 commits into
WordPress:trunkfrom
afercia:classic-editor-switch-editor-focus-override
Closed

afercia wants to merge 3 commits into
WordPress:trunkfrom
afercia:classic-editor-switch-editor-focus-override

Conversation

@afercia

@afercia afercia commented Sep 16, 2026

Copy link
Copy Markdown
Member

Trac ticket: https://core.trac.wordpress.org/ticket/42540

Prevents setting focus to the Classic editor when switching 'Visual' and 'Code' mode by using a keyboard (actually a non-pointing device).

Use of AI Tools

None


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props afercia.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@afercia
afercia force-pushed the classic-editor-switch-editor-focus-override branch from fcbdba9 to 030e8ba Compare September 16, 2026 13:19
@afercia
afercia force-pushed the classic-editor-switch-editor-focus-override branch from 030e8ba to 047430f Compare September 18, 2026 06:33
@afercia

afercia commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

Video recording to illustrate the behavior with mouse and keyboard. Tested on Safari. Observe any previous selection and caret position is preserved. I uset a custom focus style for the ::selection to better illustrate.

Screen.Recording.2026-09-18.at.12.04.40.mov

@afercia afercia added the props-bot Adding this label triggers the Props Bot workflow for a PR. label Sep 18, 2026
@github-actions github-actions Bot removed the props-bot Adding this label triggers the Props Bot workflow for a PR. label Sep 18, 2026
wporg-sync pushed a commit that referenced this pull request Sep 18, 2026
…d to switch editor mode.

Pointing device (mouse, touch, etc.) users benefit from focus being moved to the editor when switching it from Visual to Code mode and vice-versa, as they can just keep typing without loosing the previous caret position or selection. However, moving focus is confusing and distracting to keyboard and screen reader users as they loose their place. In this case, focus should stay on the switch buttons.

Previous caret position or selection is preserved in both cases.

Developed in #13560

Props shreya0shrivastava, dannerjamanca, arkaprabhachowdhury, afercia.
Fixes #42540.


git-svn-id: https://develop.svn.wordpress.org/trunk@63759 602fd350-edb4-49c9-b593-d223f7449a82
@github-actions

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 63759
GitHub commit: a1f7749

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Sep 18, 2026
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Sep 18, 2026
…d to switch editor mode.

Pointing device (mouse, touch, etc.) users benefit from focus being moved to the editor when switching it from Visual to Code mode and vice-versa, as they can just keep typing without loosing the previous caret position or selection. However, moving focus is confusing and distracting to keyboard and screen reader users as they loose their place. In this case, focus should stay on the switch buttons.

Previous caret position or selection is preserved in both cases.

Developed in WordPress/wordpress-develop#13560

Props shreya0shrivastava, dannerjamanca, arkaprabhachowdhury, afercia.
Fixes #42540.

Built from https://develop.svn.wordpress.org/trunk@63759


git-svn-id: http://core.svn.wordpress.org/trunk@62931 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant