diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.cs index 01a6c441e4a9..7dad622a507e 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.cs @@ -677,5 +677,22 @@ public async Task When_ReadOnly_Toggled_Repeatedly() Assert.AreEqual(updatedText.Length, textBox.SelectionLength); } + +#if __ANDROID__ + [TestMethod] + public async Task When_TextBox_ImeAction_Enter() + { + var textBox = new TextBox + { + Text = "Text", + }; + + WindowHelper.WindowContent = textBox; + await WindowHelper.WaitForLoaded(textBox); + + var act = () => textBox.OnEditorAction(textBox.TextBoxView, Android.Views.InputMethods.ImeAction.Next, null); + act.Should().NotThrow(); + } +#endif } } diff --git a/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.Android.cs b/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.Android.cs index b58dcb41264a..d1a13d208573 100644 --- a/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.Android.cs +++ b/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.Android.cs @@ -555,9 +555,9 @@ public bool OnEditorAction(TextView v, [GeneratedEnum] ImeAction actionId, KeyEv { //We need to force a keypress event on editor action. //the key press event is not triggered if we press the enter key depending on the ime.options - - RaiseEvent(KeyUpEvent, new KeyRoutedEventArgs(this, global::Windows.System.VirtualKey.Enter, VirtualKeyHelper.FromModifiers(e.Modifiers))); - RaiseEvent(KeyUpEvent, new KeyRoutedEventArgs(this, global::Windows.System.VirtualKey.Enter, VirtualKeyHelper.FromModifiers(e.Modifiers))); + var modifiers = e is not null ? VirtualKeyHelper.FromModifiers(e.Modifiers) : VirtualKeyModifiers.None; + RaiseEvent(KeyUpEvent, new KeyRoutedEventArgs(this, global::Windows.System.VirtualKey.Enter, modifiers)); + RaiseEvent(KeyUpEvent, new KeyRoutedEventArgs(this, global::Windows.System.VirtualKey.Enter, modifiers)); // Action will be ImeNull if AcceptsReturn is true, in which case we return false to allow the new line to register. // Otherwise we return true to allow the focus to change correctly.