diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/TextBoxTests/TextBoxTests.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/TextBoxTests/TextBoxTests.cs
index f69d21eda770..a878eeb770ad 100644
--- a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/TextBoxTests/TextBoxTests.cs
+++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/TextBoxTests/TextBoxTests.cs
@@ -6,6 +6,7 @@
using FluentAssertions;
using FluentAssertions.Execution;
using NUnit.Framework;
+using SamplesApp.UITests.Extensions;
using SamplesApp.UITests.TestFramework;
using Uno.UITest;
using Uno.UITest.Helpers;
@@ -992,5 +993,25 @@ public void TextBox_Selection_IsReadOnly()
// Final verification of SelectedText
Assert.IsNotEmpty(readonlyTextBox.GetDependencyPropertyValue("SelectedText")?.ToString());
}
+
+ [Test]
+ [AutoRetry]
+ public void When_ClickAndDrag_SelectsDefaultText()
+ {
+
+ Run("UITests.Shared.Windows_UI_Input.PointersTests.TextBox_Pointer");
+
+ _app.WaitForElement("TestTextBox");
+
+ var textBoxRect = _app.GetPhysicalRect("TestTextBox");
+
+ var startPoint = textBoxRect.GetPointInRect(new System.Drawing.PointF(0.1f, 0.5f));
+ var endPoint = textBoxRect.GetPointInRect(new System.Drawing.PointF(0.9f, 0.5f));
+
+ _app.DragCoordinates(startPoint, endPoint);
+
+ var resultText = _app.GetText("ResultText");
+ Assert.AreEqual("Pointer Released - No text selected", resultText, "Dragging should not select text.");
+ }
}
}
diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems
index 425b3a0553f3..68778b1125da 100644
--- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems
+++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems
@@ -906,6 +906,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -2381,7 +2385,7 @@
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
@@ -6185,6 +6189,9 @@
ScrollViewer_PointerMoved.xaml
+
+ TextBox_Pointer.xaml
+
SetProtectedCursor.xaml
@@ -7192,7 +7199,7 @@
PersonPictureLateBindingPage.xaml
-
+
Pivot_CustomContent_Automated.xaml
@@ -9898,4 +9905,4 @@
-
+
\ No newline at end of file
diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Input/PointersTests/TextBox_Pointer.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Input/PointersTests/TextBox_Pointer.xaml
new file mode 100644
index 000000000000..ec8da5848dca
--- /dev/null
+++ b/src/SamplesApp/UITests.Shared/Windows_UI_Input/PointersTests/TextBox_Pointer.xaml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Input/PointersTests/TextBox_Pointer.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Input/PointersTests/TextBox_Pointer.xaml.cs
new file mode 100644
index 000000000000..03d53b7f961f
--- /dev/null
+++ b/src/SamplesApp/UITests.Shared/Windows_UI_Input/PointersTests/TextBox_Pointer.xaml.cs
@@ -0,0 +1,68 @@
+using System;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Input;
+using Uno.UI.Samples.Controls;
+using Windows.Foundation;
+
+namespace UITests.Shared.Windows_UI_Input.PointersTests
+{
+ [Sample("Pointers",
+ Description = "This sample tests an issue where dragging on a TextBox selects text incorrectly. To ensures that dragging across the TextBox does not select text unless explicitly selected.")]
+ public sealed partial class TextBox_Pointer : Page
+ {
+ public TextBox_Pointer()
+ {
+ this.InitializeComponent();
+ SetupPointerEvents();
+ }
+
+ private void SetupPointerEvents()
+ {
+ TestTextBoxBorder.PointerPressed += OnPointerPressed;
+ TestTextBoxBorder.PointerMoved += OnPointerMoved;
+ TestTextBoxBorder.PointerReleased += OnPointerReleased;
+ }
+
+ private bool _isDragging;
+ private Point? _initialPoint;
+
+ private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
+ {
+ _initialPoint = e.GetCurrentPoint(TestTextBoxBorder).Position;
+ _isDragging = false;
+ ResultText.Text = "Pointer Pressed";
+ }
+
+ private void OnPointerMoved(object sender, PointerRoutedEventArgs e)
+ {
+ if (_initialPoint is Point initialPoint)
+ {
+ var currentPoint = e.GetCurrentPoint(TestTextBoxBorder).Position;
+
+ if (Math.Abs(currentPoint.X - initialPoint.X) > 2 || Math.Abs(currentPoint.Y - initialPoint.Y) > 2)
+ {
+ _isDragging = true;
+ ResultText.Text = "Pointer Dragging";
+ }
+ }
+ }
+
+ private void OnPointerReleased(object sender, PointerRoutedEventArgs e)
+ {
+ if (_isDragging)
+ {
+ var selectedText = TestTextBox.SelectedText;
+ ResultText.Text = string.IsNullOrEmpty(selectedText)
+ ? "Pointer Released - No text selected"
+ : $"Pointer Released - Selected Text: '{selectedText}'";
+ }
+ else
+ {
+ ResultText.Text = "Pointer Released - No drag detected";
+ }
+
+ _isDragging = false;
+ _initialPoint = null;
+ }
+ }
+}