Repository navigation
SelectionLength property update when entry is focused - fix - #26213
Conversation
|
@jsuarezruiz tests should pass now |
|
@kubaflo The fix only resolves the issue when clicking the right corner of the Entry without touching the text area. If we click to focus over the text area, the issue still persists. When dynamically updating the Entry's SelectionLength on the focus event, it works as expected without the fix. Please check the video below. I'm not sure if this fix is really needed or if this issue represents a proper use case. Screen.Recording.2025-02-12.at.7.39.46.PM.mov |
|
/rebase |
57dc23d to
46c2aa8
Compare
mattleibow
left a comment
There was a problem hiding this comment.
The code idea looks good, but the GC and/or manual disposal may break it.
- Maybe check IsAlive first
- Enable tests for Windows/macOS as this is a core feature for all platforms
| @@ -0,0 +1,23 @@ | |||
| #if ANDROID || IOS | |||
There was a problem hiding this comment.
Is there a reason this is not for windows and mac as well?
There was a problem hiding this comment.
I'm not sure it will work, but let's try
|
@kubaflo any thoughts on the comment by @sheiksyedm ? |
This is what this PR aims to resolve |
|
@mattleibow I didn't find any iOS extension so I've simply added |
|
/rebase |
08e3e84 to
b4f5855
Compare
|
/azp run |
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 26213Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 26213" |
|
/azp run maui-pr-uitests |
There was a problem hiding this comment.
Pull request overview
Fixes .NET MAUI Entry SelectionLength updates not being applied when the control is focused (Android/iOS), addressing #26158 by deferring selection updates until the native control is ready to accept them.
Changes:
- iOS: defer
UITextField.SelectedTextRangeupdates via main-queue dispatch whenIEntry.IsFocusedis true. - Android: defer
EditText.SetSelection(start, end)viaPost(...)when the view is focused. - Add a HostApp repro page + Appium UI test with Android/iOS snapshot baselines.
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Core/src/Platform/iOS/TextFieldExtensions.cs | Defers selection updates on iOS when focused to ensure selection takes effect. |
| src/Core/src/Platform/Android/EditTextExtensions.cs | Defers selection updates on Android when focused via Post(...). |
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26158.cs | Adds Appium UI test validating selection behavior via screenshot. |
| src/Controls/tests/TestCases.HostApp/Issues/Issue26158.cs | Adds HostApp reproduction page for the issue. |
| src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/SelectionLengthShouldUpdateWhenEntryIsFocused.png | Adds iOS snapshot baseline for the new test. |
| src/Controls/tests/TestCases.Android.Tests/snapshots/android/SelectionLengthShouldUpdateWhenEntryIsFocused.png | Adds Android snapshot baseline for the new test. |
| { | ||
| if (editText.IsAlive()) | ||
| { | ||
| editText.SetSelection(start, end); |
| App.WaitForElement("entry"); | ||
| App.Click("entry"); | ||
| #if ANDROID | ||
| App.DismissKeyboard(); | ||
| #endif | ||
| VerifyScreenshot(); | ||
| } |
|
Azure Pipelines successfully started running 1 pipeline(s). |
The PR implementation covers both Android and iOS, so the issue attribute should reflect both affected platforms. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
### Issues Fixed Fixes #26158 |Before|After| |--|--| |<video src="https://github.com/user-attachments/assets/a0b6cebe-7fd4-4705-b32e-81cf3fe34ec7" width="300px"/>|<video src="https://github.com/user-attachments/assets/d77f61e9-f198-4fab-8c18-fdab000f94ce" width="300px"/>| --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…6213) ### Issues Fixed Fixes dotnet#26158 |Before|After| |--|--| |<video src="https://github.com/user-attachments/assets/a0b6cebe-7fd4-4705-b32e-81cf3fe34ec7" width="300px"/>|<video src="https://github.com/user-attachments/assets/d77f61e9-f198-4fab-8c18-fdab000f94ce" width="300px"/>| --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>


Issues Fixed
Fixes #26158
Screen.Recording.2024-11-29.at.02.38.46.mov
Screen.Recording.2024-11-29.at.02.36.32.mov