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 eff137eae0b5..cc7193e6b7f5 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,15 @@ 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 +<<<<<<< HEAD // TODO: include modifier info in KeyEvent constructor OnKeyPress(v, new KeyEventArgs(true, Keycode.Enter, new KeyEvent(KeyEventActions.Up, Keycode.Enter))); +======= + 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)); +>>>>>>> d023bb1f58 (fix(TextBox): Avoid NRE on Android on virtual keyboard enter) // 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.