-
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
Text selection with keyboard triggers blocks multi-selection unexpectedly #12322
Comments
Any chance to give this issue some higher priority? It's unfortunate simple text selection operations are broken when using a keyboard. /Cc @youknowriad |
Gonna take a look at this one with a group of people interested in contributing during a Hackathon on Monday! |
On the implementation front, I think the culprit here may be specifically around this computation: gutenberg/packages/dom/src/dom.js Line 183 in a06f931
It's used as part of the implementation to determine whether the ArrowDown/ArrowUp should be interpreted as traversing outside the bounds of the current input (usually in the context of using arrows to navigate between paragraphs). I believe a "buffer" was added to give some flexibility where there were some false negatives without it. The problem is the buffer increases relative to the size of the entire selection, so for a multi-line selection, it may have the inverse effect of producing a false positive (i.e. indicating that bounds are exceeded, when they've not been). I think ideally:
Neither of these are easy, and I've tried (and failed) on multiple occasions to improve the logic of this function. I may like to revisit it soon, though would encourage others to as well. (cc @ellatrix since I believe you're largely credited with original implementations of these functions) |
@geekychristine not sure if this helps or not. I remember you were working on this for a bit. |
@ellatrix mentioned in Slack earlier that she may be taking a look at this as well. |
Yes. I'll have a look right now. From your comment, it sounds like |
Thanks for working on this ❤️ However, the fix doesn't cover all the cases and it still breaks text selection with keyboard when trying to use arrow keys as one would normally do in a textarea. For example (testing on a mac): Use Shift + Down arrow to select a portion of text like in the screenshot below (demo content): Once there:
There are probably more cases. |
Gotcha, it took me a few re-reads of the issue to understand the subtlety. #12322 (comment) still seems a separate issue from what was originally reported here, but in absence of another issue let's reopen and associate your #14450 fix. |
Tested on latest master 4.5.1.
Looks like selecting text with the keyboard works differently from selecting text with the mouse. At some point the blocks multi-selection kicks in and breaks the expected behavior.
Selecting text with Shift and Arrow keys is a pretty common expectation for all users, and it's also the only selection method for users who don't use the mouse.
In the GIF below, I'm following 3 steps:
Additionally, if the selection happens on the last block there's one more breaking behavior. In the GIF below:
A similar behavior happens when starting the selection from bottom to top in the first block.
The text was updated successfully, but these errors were encountered: