Skip to content

Commit bdb3b3c

Browse files
Entry ReturnType fix (#26501)
1 parent 06cd04d commit bdb3b3c

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21109.cs

+13-3
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,25 @@ public Issue21109(TestDevice device) : base(device) { }
1212

1313
public override string Issue => "[Android] MAUI 8.0.3 -> 8.0.6 regression: custom handler with key listener no longer works";
1414

15-
[Test]
15+
[Test,Order(1)]
1616
[Category(UITestCategories.Entry)]
17-
public void EntryReturnTypeWorks()
17+
public void VerifyInitialEntryReturnTypeChange()
18+
{
19+
App.WaitForElement("WaitForStubControl");
20+
//On InitialLoading returnType should work.
21+
App.Tap("SearchEntry");
22+
VerifyScreenshot();
23+
}
24+
25+
[Test,Order(2)]
26+
[Category(UITestCategories.Entry)]
27+
public void VerifyDynamicEntryReturnTypeChange()
1828
{
1929
App.WaitForElement("WaitForStubControl");
2030

2131
// Verify that ReturnType works as expected.
2232
if (App.IsKeyboardShown())
23-
App.DismissKeyboard();
33+
App.DismissKeyboard();
2434

2535
var returnType1 = App.FindElement("ReturnTypeResult").GetText();
2636
App.Tap("ReturnTypeEntry");

src/Core/src/Handlers/Entry/EntryHandler.Android.cs

+10
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public override void SetVirtualView(IView view)
4242
// TODO: NET8 issoto - Change the return type to MauiAppCompatEditText
4343
protected override void ConnectHandler(AppCompatEditText platformView)
4444
{
45+
platformView.ViewAttachedToWindow += OnViewAttachedToWindow;
4546
platformView.TextChanged += OnTextChanged;
4647
platformView.FocusChange += OnFocusedChange;
4748
platformView.Touch += OnTouch;
@@ -52,6 +53,7 @@ protected override void ConnectHandler(AppCompatEditText platformView)
5253
protected override void DisconnectHandler(AppCompatEditText platformView)
5354
{
5455
_clearButtonDrawable = null;
56+
platformView.ViewAttachedToWindow -= OnViewAttachedToWindow;
5557
platformView.TextChanged -= OnTextChanged;
5658
platformView.FocusChange -= OnFocusedChange;
5759
platformView.Touch -= OnTouch;
@@ -64,6 +66,14 @@ protected override void DisconnectHandler(AppCompatEditText platformView)
6466
_set = false;
6567
}
6668

69+
void OnViewAttachedToWindow(object? sender, ViewAttachedToWindowEventArgs e)
70+
{
71+
if (PlatformView is null || VirtualView is null)
72+
return;
73+
74+
PlatformView.UpdateReturnType(VirtualView);
75+
}
76+
6777
public static void MapBackground(IEntryHandler handler, IEntry entry) =>
6878
handler.PlatformView?.UpdateBackground(entry);
6979

src/Core/src/Platform/Android/EditTextExtensions.cs

-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ public static void UpdateClearButtonVisibility(this EditText editText, IEntry en
201201

202202
public static void UpdateReturnType(this EditText editText, IEntry entry)
203203
{
204-
editText.SetInputType(entry);
205204
editText.ImeOptions = entry.ReturnType.ToPlatform();
206205

207206
// Restart the input on the current focused EditText

0 commit comments

Comments
 (0)