Fix Android multiline TextBox IME offsets - #21680
Conversation
|
You can test this PR using the following package version. |
|
You can test this PR using the following package version. |
|
Ok i tested exactly the version of the package the bot mentioned, i previously thought nightlies are working differently. And it fixes the issue! So glad somebody found time to deal with this, hopefully this will get merged to official releases soon 👏 |
Thanks, glad to hear that it worked! It completely broke my app so I decided to spent a bit of time to see if I could fix it rather than try hacky alternatives. Hope it makes it in the next release also so I can have by app off a alpha build! |
Yes. I am just extremely suprised that this - i would say very critical bug breaking core functionality, wasnt caught earlier by devs themselves. It frustated me so much and i cant imagine deploying mobile app to normal users with how textbox worked on mobile. Sadly so many things are open here that this issue flewed under the radar for so long. Hopefully it will get mergerged as soon as possible, so we can update to new official version of avalonia. |
Gillibald
left a comment
There was a problem hiding this comment.
Since there is no better way at the moment to expose the full text buffer on demand I am aproving this change
LGTM
|
You can test this PR using the following package version. |
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
What does the pull request do?
Fixes Android multiline
TextBoxIME offset handling.This is a minimal patch related to #20232. The issue appears when Android IME operations such as selection updates, newline input, and backspace interact with multiline
TextBoxcontent.This was originally reproduced and tested against 12.0.5. This PR targets
masteras requested, and may be suitable for a 12.0.x backport.What is the current behavior?
TextBoxTextInputMethodClientreportsSurroundingTextandSelectionusing offsets relative to the current visual text line.On Android multiline
TextBoxinput, this can cause IME operations to target the wrong document offsets after the caret moves onto later lines. In practice this shows up as backspace/newline/caret drift in multiline text.What is the updated/expected behavior with this PR?
The IME client now reports full-document surrounding text and document-wide selection offsets.
This keeps Android IME selection, deletion, and composition operations aligned with the actual
TextBoxdocument positions in multiline text.Validation:
SurroundingText.Selectionwith document offsets.Avalonia.Controls.UnitTests.TextBoxTestspasses: 164 passed, 0 failed.How was the solution implemented (if it's not obvious)?
TextBoxTextInputMethodClient.SurroundingTextnow returns the fullTextBox.Textinstead of extracting the current text line fromTextLayout.TextBoxTextInputMethodClient.Selectionnow gets and setsTextBox.SelectionStart/TextBox.SelectionEnddirectly as document offsets, instead of translating through the current line start.This also replaces the anonymous
CaretBoundsChangedsubscription with a stored event handler so the old presenter can be unsubscribed correctly.Checklist
Breaking changes
None.
Obsoletions / Deprecations
None.
Fixed issues
Fixes #20232