From f6976f88efe0c8c9e28af7845f707a37d449ceef Mon Sep 17 00:00:00 2001 From: David Date: Fri, 10 May 2024 17:20:36 -0400 Subject: [PATCH] fix: Fix space and enter keys in TB while in ListView (cherry picked from commit cc5c4528a41ac46f7d3a56e92f7ca9aa3127b3a6) --- .../UITests.Shared/UITests.Shared.projitems | 7 ++++++ .../ListView_KeyboardInterception.xaml | 23 +++++++++++++++++++ .../ListView_KeyboardInterception.xaml.cs | 15 ++++++++++++ .../Controls/ListViewBase/ListViewBase.cs | 4 ++++ 4 files changed, 49 insertions(+) create mode 100644 src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_KeyboardInterception.xaml create mode 100644 src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_KeyboardInterception.xaml.cs diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems index aea4c8325cd0..56cc66dd440c 100644 --- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems +++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems @@ -3410,6 +3410,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -7506,6 +7510,9 @@ ListView_ItemTemplateSelector_And_ItemContainerStyleSelector.xaml + + ListView_KeyboardInterception.xaml + ListView_TextBox.xaml diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_KeyboardInterception.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_KeyboardInterception.xaml new file mode 100644 index 000000000000..4696c1f21da6 --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_KeyboardInterception.xaml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_KeyboardInterception.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_KeyboardInterception.xaml.cs new file mode 100644 index 000000000000..a8a392b6bb34 --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_KeyboardInterception.xaml.cs @@ -0,0 +1,15 @@ +using System; +using System.Linq; +using Uno.UI.Samples.Controls; +using Microsoft.UI.Xaml.Controls; + +namespace UITests.Windows_UI_Xaml_Controls.ListView; + +[SampleControlInfo("ListView", "ListView_KeyboardInterception", Description = "Validate that we can add spaces and enter in TextBox that are in a ListView", IsManualTest = true)] +public sealed partial class ListView_KeyboardInterception : Page +{ + public ListView_KeyboardInterception() + { + this.InitializeComponent(); + } +} diff --git a/src/Uno.UI/UI/Xaml/Controls/ListViewBase/ListViewBase.cs b/src/Uno.UI/UI/Xaml/Controls/ListViewBase/ListViewBase.cs index 4267de314976..46d73dd9773d 100644 --- a/src/Uno.UI/UI/Xaml/Controls/ListViewBase/ListViewBase.cs +++ b/src/Uno.UI/UI/Xaml/Controls/ListViewBase/ListViewBase.cs @@ -101,6 +101,10 @@ internal bool TryHandleKeyDown(KeyRoutedEventArgs args) { OnItemClicked(focusedContainer, args.KeyboardModifiers); } + +#if __WASM__ + ((IHtmlHandleableRoutedEventArgs)args).HandledResult &= ~HtmlEventDispatchResult.PreventDefault; +#endif return true; } else