Skip to content

SelectionLength in Entry and Editor behaves differently on Android and Windows if the user selected the text from right to left #30782

@holecekp

Description

@holecekp

Description

SelectionLength in Entry and Editor is updated correctly if the user selects the text from the left to the right (for example, by pressing the Shift together with the right arrow) However, if the user selects the text in the opposite direction (Shift + left arrow), the reported SelectionLength differs among the platforms. On Android it reports 0 which is incorrect. On Windows, it is the correct non-zero value corresponding to the real selection length.

Example on Android:
Text selected from the left:
Image

Different values for the same selection when it is done from the righ. SelectionLength is reported to be 0, which is incorrect):
Image

Steps to Reproduce

  1. Clone the reproduction project https://github.com/holecekp/MauiCursorPositionBug
  2. Run it on Android
  3. There is a SearchBar, an Entry and an Editor. Type the text "Test" into the Entry in the middle of the page.
  4. Click on the beginning of the Entry and press Shift+right arrow until you select the whole text. You can see that the Label with the SelectionLength is updated correctly.
  5. Click on the end of text in the Entry and press Shift+left arrow until you select the whole text. You can see that the SelectionLength is not updated and is 0, which is incorrect.
  6. You can verify that the same problem is also in the Editor control. You can skip testing this for the SearchBar, which is also on the page, because the SearchBar is completely broken and doesn't work correctly in either direction on Android (already reported as SearchBar - CursorPosition and SelectionLength are not updated when the user types #30779).
  7. You can verify, that the problem is only on Android and the same app on Windows reports the correct values of CursorPosition and SelectionLength. They are the same regardless in which direction was the text selected. I haven't tested the behavior on iOS and Mac.

Android (the text "Test" selected from left to right) - CursorPosition=0, SelectionLength=4 (correct)
Android (the text "Test" selected from right to left) - CursorPosition=4, SelectionLength=0 (incorrect)

Windows (the text "Test" selected from left to right) - CursorPosition=0, SelectionLength=4 (correct)
Windows (the text "Test" selected from right to left) - CursorPosition=0, SelectionLength=4 (correct)

Link to public reproduction project repository

https://github.com/holecekp/MauiCursorPositionBug

Version with bug

9.0.90 SR9

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 15

Did you find any workaround?

No

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions