-
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: maintain correct selection after drag-selecting outside block #58684
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @toncijajic. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. Core SVNIf you're a Core Committer, use this list when committing to
GitHub Merge commitsIf 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: +22 B (0%) Total Size: 1.69 MB
ℹ️ View Unchanged
|
Flaky tests detected in 3ebac69. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7788655417
|
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.
Testing well. I can't break it, and I've been trying hard :)
Cherry picked this PR |
What?
The problem here is that the browser sort of destroys the selection after refocussing the editable element.
When dragging outside a block, we prepare the editor for (partial & full) multi-selection by making the whole editor
contenteditable
. When you end the drag selection, but there is no multi selection, we need refocus the element where the selection started. The browser seems to not preserve the selection correctly on focus, so we have to clone the selection before focus, then restore it.I've added a test that currently fails with trunk.
Why?
Fixes #57894.
How?
Testing Instructions
With a single paragraph and some text, start a selection by dragging to the right but not to the end, then down to select the whole paragraph. Stop dragging. The selection to the end of the paragraph should be preserved.
Testing Instructions for Keyboard
Screenshots or screencast