diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems
index 176ea36b8b3f..d59d12e62c59 100644
--- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems
+++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems
@@ -1414,10 +1414,6 @@
Designer
MSBuild:Compile
-
- Designer
- MSBuild:Compile
-
Designer
MSBuild:Compile
@@ -6562,9 +6558,6 @@
AutoSuggestBox_Description.xaml
-
- AutoSuggestBox_PopupFocus.xaml
-
AutoSuggestBox_Icons.xaml
diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/AutoSuggestBoxTests/AutoSuggestBox_PopupFocus.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/AutoSuggestBoxTests/AutoSuggestBox_PopupFocus.xaml
deleted file mode 100644
index e87af73d130d..000000000000
--- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/AutoSuggestBoxTests/AutoSuggestBox_PopupFocus.xaml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/AutoSuggestBoxTests/AutoSuggestBox_PopupFocus.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/AutoSuggestBoxTests/AutoSuggestBox_PopupFocus.xaml.cs
deleted file mode 100644
index a15b251f5cb3..000000000000
--- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/AutoSuggestBoxTests/AutoSuggestBox_PopupFocus.xaml.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using Uno.UI.Samples.Controls;
-using Microsoft.UI.Xaml.Controls;
-
-namespace UITests.Windows_UI_Xaml_Controls.AutoSuggestBoxTests;
-
-[Sample("AutoSuggestBox", IsManualTest = true)]
-public sealed partial class AutoSuggestBox_PopupFocus : Page
-{
- public AutoSuggestBox_PopupFocus()
- {
- this.InitializeComponent();
- }
-}
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 a25f8b786c71..a34dd21378a8 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
@@ -28,6 +28,7 @@
using Windows.UI.Input.Preview.Injection;
using Windows.Foundation;
using System.Collections.Generic;
+using Uno.Extensions;
#if WINAPPSDK
@@ -1124,6 +1125,44 @@ static FrameworkElement GetSCP(TextBox tb)
}
#endif
+#if HAS_UNO
+ [TestMethod]
+ [UnoWorkItem("https://github.com/unoplatform/uno/issues/18790")]
+#if !HAS_INPUT_INJECTOR
+ [Ignore("InputInjector is not supported on this platform.")]
+#endif
+ public async Task When_Clicked_In_Popup()
+ {
+ TextBox tb;
+ var btn = new Button
+ {
+ Flyout = new Flyout
+ {
+ Content = tb = new TextBox()
+ }
+ };
+
+ await UITestHelper.Load(btn);
+
+ var injector = InputInjector.TryCreate() ?? throw new InvalidOperationException("Failed to init the InputInjector");
+ using var mouse = injector.GetMouse();
+
+ mouse.Press(btn.GetAbsoluteBoundsRect().GetCenter());
+ await UITestHelper.WaitForIdle();
+ mouse.Release();
+ await UITestHelper.WaitForIdle();
+
+ Assert.IsTrue(btn.Flyout.IsOpen);
+
+ mouse.Press(tb.GetAbsoluteBoundsRect().GetCenter());
+ await UITestHelper.WaitForIdle();
+ mouse.Release();
+ await UITestHelper.WaitForIdle();
+
+ Assert.AreEqual(tb, FocusManager.GetFocusedElement(WindowHelper.XamlRoot));
+ }
+#endif
+
private static async Task LoadZeroSizeTextBoxAsync(Style style)
{
var loaded = false;
diff --git a/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.cs b/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.cs
index d6c17d460f8b..ff8b34c65ab3 100644
--- a/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.cs
+++ b/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.cs
@@ -593,17 +593,6 @@ public double HorizontalOffset
);
#endregion
-#if __WASM__
- ///
- /// This is specifically added for ScrollViewers inside TextBoxes and specifically for WASM
- /// On WASM, a click on a TextBox inside a popup shifts focus to the Popup instead of the TextBox
- /// as a result of ScrollContentControl_SetFocusOnFlyoutLightDismissPopupByPointer.
- /// This is only a problem on WASM because we don't capture the pointer when pressing inside a TextBox
- /// .
- ///
- internal bool DisableSetFocusOnPopupByPointer { get; set; }
-#endif
-
private readonly SerialDisposable _sizeChangedSubscription = new SerialDisposable();
#pragma warning disable 649 // unused member for Unit tests
diff --git a/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.wasm.cs b/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.wasm.cs
index e709cb5ac605..185369d583cd 100644
--- a/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.wasm.cs
+++ b/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.wasm.cs
@@ -11,6 +11,15 @@ namespace Microsoft.UI.Xaml.Controls
{
partial class ScrollViewer
{
+ ///
+ /// This is specifically added for ScrollViewers inside TextBoxes and specifically for WASM
+ /// On WASM, a click on a TextBox inside a popup shifts focus to the Popup instead of the TextBox
+ /// as a result of ScrollContentControl_SetFocusOnFlyoutLightDismissPopupByPointer.
+ /// This is only a problem on WASM because we don't capture the pointer when pressing inside a TextBox
+ /// .
+ ///
+ internal bool DisableSetFocusOnPopupByPointer { get; set; }
+
internal bool CancelNextNativeScroll { get; private set; }
internal Size ScrollBarSize => (_presenter as ScrollContentPresenter)?.ScrollBarSize ?? default;