Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Text selection with keyboard triggers blocks multi-selection unexpectedly #12322
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.
referenced this issue
Dec 8, 2018
On the implementation front, I think the culprit here may be specifically around this computation:
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)
referenced this issue
Mar 15, 2019
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):
There are probably more cases.