Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Fix for Entry SelectionLength #24064

Merged
merged 14 commits into from
Aug 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/Core/src/Handlers/Entry/EntryHandler.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public override void SetVirtualView(IView view)
// TODO: NET8 issoto - Change the return type to MauiAppCompatEditText
protected override void ConnectHandler(AppCompatEditText platformView)
{
platformView.ViewAttachedToWindow += OnPlatformViewAttachedToWindow;
platformView.TextChanged += OnTextChanged;
platformView.FocusChange += OnFocusedChange;
platformView.Touch += OnTouch;
Expand All @@ -52,7 +53,7 @@ protected override void ConnectHandler(AppCompatEditText platformView)
protected override void DisconnectHandler(AppCompatEditText platformView)
{
_clearButtonDrawable = null;

platformView.ViewAttachedToWindow -= OnPlatformViewAttachedToWindow;
platformView.TextChanged -= OnTextChanged;
platformView.FocusChange -= OnFocusedChange;
platformView.Touch -= OnTouch;
Expand Down Expand Up @@ -146,6 +147,16 @@ static void MapFocus(IEntryHandler handler, IEntry entry, object? args)
handler.PlatformView.Focus(request);
}

void OnPlatformViewAttachedToWindow(object? sender, ViewAttachedToWindowEventArgs e)
{
if (PlatformView.IsAlive() && PlatformView.Enabled)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

I'm thinking you'll be able to add visual tests for this one. If you can't get an automated test for this PR just let us know and we can add a manual one internally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added visual test for this. Please verify

{
// https://issuetracker.google.com/issues/37095917
PlatformView.Enabled = false;
PlatformView.Enabled = true;
}
}

void OnTextChanged(object? sender, TextChangedEventArgs e)
{
if (VirtualView == null)
Expand Down