Skip to content

[SelectableText] inconsistent selection background color between different character encoding #68675

Closed

Description

@renntbenrennt

Steps to Reproduce

Select text when text containing English and Chinese, the selection color isn't cover the all the text while part of it is smaller if English is selected while another part of it is bigger if Chinese is selected.

Expected results:
image

Actual results:
image

Activity

  1. darshankawar commented on Oct 21, 2020

    @darshankawar
    Member

    @SeasonLeee
    Please provide flutter doctor -v and a complete minimal reproducible code sample that shows the issue.
    Thanks.

  2. added
    in triagePresently being triaged by the triage team
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Oct 21, 2020
  3. renntbenrennt commented on Oct 21, 2020

    @renntbenrennt
    Author

    No problem, here's the flutter doctor -v:
    image

    And I don't think this issue is sdk specific, it's been there for a while I just don't have the time to open a issue to talk about it, thanks

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Oct 21, 2020
  5. darshankawar commented on Oct 21, 2020

    @darshankawar
    Member

    @SeasonLeee
    It's probably the way the selection toolbar works depending on the language and it's height. Since the English letters are a bit smaller than Chinese characters, it interprets and selects based on the height. As an example, Russian is same height as English, so the selection height would be same, but if you see the chinese characters, they are bigger and hence the difference.

  6. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Oct 21, 2020
  7. renntbenrennt commented on Oct 21, 2020

    @renntbenrennt
    Author

    Yeah, it could be, but I can't be sure the code to paint that background color, could you point me to the file that control the painting? thanks! @darshankawar

  8. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Oct 21, 2020
  9. darshankawar commented on Oct 21, 2020

    @darshankawar
    Member

    @SeasonLeee
    Check this if it helps.

  10. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Oct 21, 2020
  11. renntbenrennt commented on Oct 21, 2020

    @renntbenrennt
    Author

    @darshankawar oh, man, it's too much... 😅... I just tried to track down something related to SelectableText... but... ugh... I feel like I'm lost in the jungle...😅, thanks, though...

  12. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Oct 21, 2020
  13. jamesblasco commented on Oct 21, 2020

    @jamesblasco
    Contributor

    I think this would be possible to edit by using the param selectionHeightStyle : BoxHeightStyle.max in EditableText;

    /// Controls how tall the selection highlight boxes are computed to be.
    ///
    /// See [ui.BoxHeightStyle] for details on available styles.
    final ui.BoxHeightStyle selectionHeightStyle;

    Sadly this param is not accessible from SelectableText, TextField, TextFormField, CupertinoTextField.'

    @justinmc, What would you think about adding this param to the TextSelectionThemeData?

    I also noticed that selectionHeightStyle : BoxHeightStyle.max should be the default one in Cupertino. Now all EditableText default to selectionHeightStyle : BoxHeightStyle.tight

    Apple Mail App:

  14. renntbenrennt commented on Oct 21, 2020

    @renntbenrennt
    Author

    @jamesblasco Wow! words are useless when I want to use them to express my amazement on how quick you locate the cause was!!!! Man, you are brilliant!!! And huge thank you for check this out!!!!!!!!!!!!

    And yes, I agree with that we should expose the setting of selectionHeightStyle or at least make it default to BoxHeightStyle.max instead of the original BoxHeightStyle.tight

    Although, the reason why tight is the default maybe the fact that there's some problem with max when the text has change into new line if I understand correctly?

    As stated in the codebase's comment:
    image

  15. 19 remaining items

  16. mafreud commented on Aug 6, 2024

    @mafreud

    Is it okay to set selectionHeightStyle : BoxHeightStyle.includeLineSpacingMiddle as a default?

  17. added and removed
    team-designOwned by Design Languages team
    triaged-designTriaged by Design Languages team
    on Apr 22, 2025
  18. added
    P2Important issues not at the top of the work list
    on Apr 24, 2025
  19. added a commit that references this issue on Jun 16, 2025
    fe6c969
  20. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jun 17, 2025
  21. github-actions commented on Jul 1, 2025

    @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.

  22. locked as resolved and limited conversation to collaborators on Jul 1, 2025
  23. added a commit that references this issue on Jul 21, 2025
    ec93087
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsf: selectionSelectableRegion, SelectionArea, SelectionContainer, Selectable, and related APIsframeworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionteam-text-inputOwned by Text Input teamtriaged-text-inputTriaged by Text Input team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions