Skip to content

Add awareness for cursor position in selection-related behaviors across desktop platforms #57679

Description

@stuartmorgan-g

My recollection from working on Gecko macOS text selection many years ago is that desktop platforms have different expected behaviors around how keyboard text selection interacts with existing selections, especially mouse-based. In particular: if you select some text, then shift-left-arrow or shift-right-arrow, what happens? Does it matter if the text was selected from left to right or right to left with the mouse?

We should audit this behavior on each desktop platform in a native text field, then make sure the framework handling matches on each platform.

Activity

  1. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    platform-macosBuilding on or for macOS specifically
    platform-windowsBuilding on or for Windows specifically
    a: qualityA truly polished experience
    platform-linuxBuilding on or for Linux specifically
    on May 20, 2020
  2. stuartmorgan-g commented on May 20, 2020

    @stuartmorgan-g
    ContributorAuthor

    Related note: @robert-ancell noticed that the base and extent reported by the framework doesn't seem to be different for left-to-right vs right-to-left selection, which may be an issue for getting correct behavior everywhere.

  3. added
    P3Issues that are less important to the Flutter project
    on Jun 9, 2020
  4. justinmc commented on Dec 5, 2020

    @justinmc
    Contributor

    Tl;dr: All native platforms agree on this behavior, but Flutter behaves differently and needs to be updated.

    The pivot point is the edge of the selection that remains fixed during the shift/arrow operations before any reversal. Here is an example of each on Mac:

    Pivot point left Pivot point right
    pivot_left pivot_right

    For a selection in the middle of the text made with a mouse in the given direction, the behavior is given when holding shift and using the arrow keys.

    Flutter OSX 10.15.7 TextEdit Windows 10 Home Notepad Ubuntu 20.04.1 LTS TextEditor
    Left to right Pivot point right Pivot point right Pivot point right Pivot point right
    Right to left Pivot point right Pivot point left Pivot point left Pivot point left

    Is there anything else I'm missing that I should try? Otherwise it seems that Flutter just needs to adjust its behavior to match all the other platforms (no need to adjust per-platform).

    I confirmed that Flutter's TextSelection has its base set to the lowest point and extent set to the highest, regardless of the direction of the selection. So indeed, TextSelection does not currently have the information we need to change the pivot point unfortunately.

    Here is where we are swapping base and extent to be in ascending order in the codebase:

    if (toPosition != null) {
    baseOffset = math.min(fromPosition.offset, toPosition.offset);
    extentOffset = math.max(fromPosition.offset, toPosition.offset);
    }

    Edit This is now fixed in #71756.

  5. 4 remaining items

  6. justinmc commented on Dec 14, 2020

    @justinmc
    Contributor

    Sorry, this shouldn't have been closed since #71756 only fixes the first problem mentioned (#57679 (comment)) and not the other problems I found in #57679 (comment).

  7. kf6gpe commented on Jan 12, 2021

    @kf6gpe
    Contributor

    /cc @csells, who did some of this in Q3.

  8. changed the title [-]Audit mouse+keyboard selection behaviors across desktop platforms[/-] [+]Add awareness for cursor position in selection-related behaviors across desktop platforms[/+] on Jan 19, 2021
  9. removed their assignment
    on Jan 28, 2021
  10. kf6gpe commented on Mar 2, 2021

    @kf6gpe
    Contributor

    @justinmc We think this may be done --- can you confirm and close if corrrect? Thanks!

  11. justinmc commented on Mar 3, 2021

    @justinmc
    Contributor

    PR #71756 fixed the main problem, but the issue kind of expanded in scope when I went through all of the inconsistencies on all the different platforms in #57679 (comment).

    I say let's keep this open until I can match all of the behavior in the table in that comment. Or I can always move that to a separate issue if you think that's better.

  12. cbracken commented on Mar 9, 2021

    @cbracken
    Member

    @justinmc if we're going to keep this one open rather than open a new bug, it would be useful to update the above table to show which behaviours are working and which still need to be done.

  13. justinmc commented on Mar 10, 2021

    @justinmc
    Contributor

    Good call. I've updated the table in #57679 (comment) to match the current behavior. #75032 will fix some of these and I will update the table again when it's merged.

  14. removed their assignment
    on Mar 15, 2021
  15. justinmc commented on Mar 18, 2021

    @justinmc
    Contributor

    I've updated the table of behaviors at #57679 (comment) now that #75032 has been merged. It looks like it actually fixed a few of them, but there are still some differences that need to be manually tweaked.

  16. justinmc commented on Mar 18, 2021

    @justinmc
    Contributor

    I've created this issue to track Windows inconsistencies: #78572.

    This PR will fix all Mac problems here and will close this issue: #78573.

  17. github-actions commented on Aug 4, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  18. locked as resolved and limited conversation to collaborators on Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3Issues that are less important to the Flutter projecta: desktopRunning on desktopa: qualityA truly polished experienceframeworkflutter/packages/flutter repository. See also f: labels.platform-linuxBuilding on or for Linux specificallyplatform-macosBuilding on or for macOS specificallyplatform-windowsBuilding on or for Windows specifically

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions