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

[web] Fix text selection from right to left #24214

Merged
merged 1 commit into from
Feb 5, 2021

Conversation

mdebbar
Copy link
Contributor

@mdebbar mdebbar commented Feb 4, 2021

When the user uses a mouse to select text dragging from right to left, the selection keeps flickering, and copying doesn't work. (dragging from left to right works fine).

This was introduced in flutter/flutter#71756. The framework started allowing reverse base/extent offsets for selection. That throws off the <input>/<textarea> DOM element.

Fixes flutter/flutter#74504

@mdebbar mdebbar added affects: text input platform-web Code specifically for the web engine labels Feb 4, 2021
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Thanks for fixing this. I knew I was going to break something when I started allowing reversed base/extent.

Is Flutter Web able to distinguish between selections made left-to-right vs. right-to-left? Or I'm guessing that part is handled by the browser and Flutter doesn't care which direction the selection was made from?

I'm talking about cases like this:

abc|def|g

Then shift + left arrow is pressed. If the selection was made with the mouse left to right then it will look like this:

abc|de|fg

But if it was made right to left then it would be:

ab|cdef|g

@mdebbar
Copy link
Contributor Author

mdebbar commented Feb 4, 2021

@justinmc the browser always uses base/extent in order. Even if you select from right to left, the browser doesn't revert base/extent. You can try it here: https://jsfiddle.net/ex736p81/2/

@justinmc
Copy link
Contributor

justinmc commented Feb 4, 2021

Ah thanks, you're right! It must be keeping track of the direction or something like that elsewhere. Well I guess as long as the behavior is the same then it's all good.

@mdebbar mdebbar added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Feb 4, 2021
@fluttergithubbot fluttergithubbot merged commit 89351fe into flutter:master Feb 5, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 5, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 5, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 5, 2021
christopherfujino pushed a commit to christopherfujino/engine that referenced this pull request Feb 9, 2021
christopherfujino added a commit that referenced this pull request Feb 10, 2021
…24306)

* Update Dart SDK to 2.12.0-259.9.beta
* Fixed plumbing of the spawning isolate for Shell::Spawn. (#24112)
* [canvaskit] update CSS size of the canvas when device-pixel ratio changes (#24160)
* [web] Fix text selection from right to left (#24214)
* [windows] Surface will not update when restoring (#24236)

Co-authored-by: gaaclarke <30870216+gaaclarke@users.noreply.github.com>
Co-authored-by: Yegor <yjbanov@google.com>
Co-authored-by: Mouad Debbar <mouad.debbar@gmail.com>
Co-authored-by: Kaushik Iska <iska.kaushik@gmail.com>
hjfreyer pushed a commit to hjfreyer/engine that referenced this pull request Mar 22, 2021
@mdebbar mdebbar deleted the fix_selection_reverse branch April 15, 2021 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects: text input cla: yes platform-web Code specifically for the web engine waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[web] Text selection from right to left inside text fields is broken
4 participants