Skip to content

SearchBar - CursorPosition and SelectionLength are not updated when the user types #30779

@holecekp

Description

@holecekp

Description

SearchBar.CursorPosition and SelectionLength properties don't work correctly. When the user types, they are still 0. These two properties works in Entry and Editor but not in SearchBar

Image

Steps to Reproduce

  1. Clone the reproduction project https://github.com/holecekp/MauiCursorPositionBug/
  2. Run it on Android
  3. There are 3 input controls - a SearchBar, an Entry and an Editor. Type any text into the SearchBar. You can observe that the cursor moves but the SearchBar.CursorPosition is still 0.
  4. You can move the cursor to the beginning of the SearchBar text and press Shift+right arrow to select a part of the text. You can check that even if the selection is changed, the SearchBar.SelectionLength property is still 0.
  5. Try the above steps also for the Entry and Editor - it works. This bug affects the SearchBar control only.
  6. Run the project on Windows and repeat the above steps. You can see the same bug also on Windows (I haven't tested iOS and Mac).

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, Windows, I was not able test on other platforms

Affected platform versions

Tested on Android 15, Windows 11, probably version of OS doesn't matter

Did you find any workaround?

No. Maybe ignroing MAUI properties and get the cursor position and the selection length from the Android control myself would be possibe in certain situations when one doesn't need databinding to these properties.

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