[Android] Fix for Entry SelectionLength (#24064)
* fix-18443-SelectionLength Property Not Applied to Entry at Runtime * Added UI test for 18443 * Modified the test case * Modified test file * Modified TestCases.Shared.Tests/Tests/Issues/Issue18443.cs * Modified test file * Modified test case * Added image for Entry test
This commit is contained in:
Родитель
2aca52006a
Коммит
ebf760463b
Двоичные данные
src/Controls/tests/TestCases.Android.Tests/snapshots/android/EntrySelectionLengthRuntimeUpdate.png
Normal file
Двоичные данные
src/Controls/tests/TestCases.Android.Tests/snapshots/android/EntrySelectionLengthRuntimeUpdate.png
Normal file
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 86 KiB |
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Maui.Controls.Sample.Issues.Issue18443">
|
||||
|
||||
<Entry AutomationId="entry" x:Name="MauiEntry" Text="Microsoft Maui Entry" SelectionLength="5" HeightRequest="75"></Entry>
|
||||
|
||||
</ContentPage>
|
|
@ -0,0 +1,21 @@
|
|||
namespace Maui.Controls.Sample.Issues
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
[Issue(IssueTracker.Github, 18443, "SelectionLength Property Not Applied to Entry at Runtime", PlatformAffected.Android)]
|
||||
public partial class Issue18443 : ContentPage
|
||||
{
|
||||
public Issue18443()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override async void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
await Task.Delay(1000);
|
||||
MauiEntry.Focus();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
#if ANDROID
|
||||
using NUnit.Framework;
|
||||
using UITest.Appium;
|
||||
using UITest.Core;
|
||||
namespace Microsoft.Maui.TestCases.Tests.Issues
|
||||
{
|
||||
public class Issue18443 : _IssuesUITest
|
||||
{
|
||||
public Issue18443(TestDevice device) : base(device) { }
|
||||
|
||||
public override string Issue => "SelectionLength Property Not Applied to Entry at Runtime";
|
||||
|
||||
[Test]
|
||||
[Category(UITestCategories.Entry)]
|
||||
public void EntrySelectionLengthRuntimeUpdate()
|
||||
{
|
||||
App.WaitForElement("entry");
|
||||
VerifyScreenshot();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -42,6 +42,7 @@ namespace Microsoft.Maui.Handlers
|
|||
// 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;
|
||||
|
@ -52,7 +53,7 @@ namespace Microsoft.Maui.Handlers
|
|||
protected override void DisconnectHandler(AppCompatEditText platformView)
|
||||
{
|
||||
_clearButtonDrawable = null;
|
||||
|
||||
platformView.ViewAttachedToWindow -= OnPlatformViewAttachedToWindow;
|
||||
platformView.TextChanged -= OnTextChanged;
|
||||
platformView.FocusChange -= OnFocusedChange;
|
||||
platformView.Touch -= OnTouch;
|
||||
|
@ -146,6 +147,16 @@ namespace Microsoft.Maui.Handlers
|
|||
handler.PlatformView.Focus(request);
|
||||
}
|
||||
|
||||
void OnPlatformViewAttachedToWindow(object? sender, ViewAttachedToWindowEventArgs e)
|
||||
{
|
||||
if (PlatformView.IsAlive() && PlatformView.Enabled)
|
||||
{
|
||||
// https://issuetracker.google.com/issues/37095917
|
||||
PlatformView.Enabled = false;
|
||||
PlatformView.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
void OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (VirtualView == null)
|
||||
|
|
Загрузка…
Ссылка в новой задаче