Skip to content

Commit b076f33

Browse files
Address copilot suggestion
1 parent 14feef8 commit b076f33

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

src/Controls/src/Core/Entry/Entry.Android.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ public static void MapText(IEntryHandler handler, Entry entry)
3232

3333
// TODO: Material3: Make it public in .NET 11
3434
// MaterialEntryHandler-specific overloads
35+
internal static void MapImeOptions(EntryHandler2 handler, Entry entry)
36+
{
37+
if (handler.PlatformView?.EditText is null)
38+
{
39+
return;
40+
}
41+
42+
Platform.EditTextExtensions.UpdateImeOptions(handler.PlatformView.EditText, entry);
43+
}
44+
45+
// TODO: Material3: Make it public in .NET 11
3546
internal static void MapText(EntryHandler2 handler, Entry entry)
3647
{
3748
if (handler.PlatformView?.EditText is null)

src/Controls/src/Core/Entry/Entry.Mapper.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ public partial class Entry
2424
#if ANDROID
2525
if (RuntimeFeature.IsMaterial3Enabled)
2626
{
27+
EntryHandler2.Mapper.ReplaceMapping<Entry, EntryHandler2>(PlatformConfiguration.AndroidSpecific.Entry.ImeOptionsProperty.PropertyName, MapImeOptions);
2728
EntryHandler2.Mapper.ReplaceMapping<Entry, EntryHandler2>(nameof(Text), MapText);
2829
EntryHandler2.Mapper.ReplaceMapping<Entry, EntryHandler2>(nameof(TextTransform), MapText);
30+
EntryHandler2.Mapper.AppendToMapping(nameof(VisualElement.IsFocused), InputView.MapIsFocused);
31+
EntryHandler2.CommandMapper.PrependToMapping(nameof(IEntry.Focus), InputView.MapFocus);
2932
}
3033
#endif
3134

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ static void MapFocus(EntryHandler2 handler, IEntry entry, object? args)
230230
{
231231
if (args is FocusRequest request)
232232
{
233-
handler.PlatformView.Focus(request);
233+
// Focus the EditText directly, not the TextInputLayout container
234+
handler.PlatformView.EditText?.Focus(request);
234235
}
235236
}
236237

@@ -275,7 +276,7 @@ void OnEditorAction(object? sender, EditorActionEventArgs e)
275276
{
276277
var actionId = e.ActionId;
277278
var evt = e.Event;
278-
ImeAction currentInputImeFlag = PlatformView.EditText!.ImeOptions;
279+
ImeAction currentInputImeFlag = PlatformView.EditText?.ImeOptions ?? ImeAction.None;
279280

280281
// On API 34 it looks like they fixed the issue where the actionId is ImeAction.ImeNull when using a keyboard
281282
// so I'm just setting the actionId here to the current ImeOptions so the logic can all be simplified
@@ -297,7 +298,7 @@ void OnEditorAction(object? sender, EditorActionEventArgs e)
297298
else if (evt?.KeyCode is null && (actionId == ImeAction.Done || actionId == currentInputImeFlag))
298299
{
299300
VirtualView?.Completed();
300-
// In case of Search, Go, Send the EditorAction will be invoked for KeyEventActions which will cause Completed to inovke twice
301+
// In case of Search, Go, Send the EditorAction will be invoked for KeyEventActions which will cause Completed to invoke twice
301302
//So for these setting handled to true
302303
if (actionId == ImeAction.Search ||
303304
actionId == ImeAction.Go ||

0 commit comments

Comments
 (0)