From e72f6adaab6692ebb7a23ddbf7e7be15c9684e39 Mon Sep 17 00:00:00 2001 From: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com> Date: Sat, 7 Dec 2024 03:17:12 +0530 Subject: [PATCH] Fixed the double tap editor freeze issue and added test cases (#26203) * Fixed the double tap editor freeze issue and added test cases * Remove the platform specific code * Modified the test cases * Modified the test cases * Modified the test cases * Modified the assert at last * Modified the test cases * Modified the test cases --------- Co-authored-by: Shalini-Ashokan <102292178+Shalini-Ashokan@users.noreply.github.com> --- .../TestCases.HostApp/Issues/Issue25975.cs | 32 +++++++++++++++++++ .../Tests/Issues/Issue25975.cs | 31 ++++++++++++++++++ .../src/Handlers/Editor/EditorHandler.iOS.cs | 6 ++-- 3 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue25975.cs create mode 100644 src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25975.cs diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue25975.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue25975.cs new file mode 100644 index 000000000000..50be08b34962 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue25975.cs @@ -0,0 +1,32 @@ +namespace Maui.Controls.Sample.Issues +{ + [Issue(IssueTracker.Github, 25975, "Double tapping Editor control locks app", PlatformAffected.All)] + public class Issue25975 : TestContentPage + { + protected override void Init() + { + var editor = new Editor() + { + Text = "MAUI", + AutomationId = "DoubleTapEditor", + FontSize = 24, + MaxLength = 5, + HorizontalTextAlignment = TextAlignment.Center, + VerticalOptions = LayoutOptions.Center, + HorizontalOptions = LayoutOptions.Fill, + AutoSize = EditorAutoSizeOption.TextChanges, + }; + + var stackLayout = new StackLayout() + { + Children = + { + editor + } + }; + + Content = stackLayout; + + } + } +} diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25975.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25975.cs new file mode 100644 index 000000000000..b54036585231 --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25975.cs @@ -0,0 +1,31 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues +{ + public class Issue25975 : _IssuesUITest + { + public Issue25975(TestDevice device) + : base(device) + { } + + public override string Issue => "Double tapping Editor control locks app"; + + [Test] + [Category(UITestCategories.Editor)] + public void PerformDoubleTapActionOnEditor() + { + App.WaitForElement("DoubleTapEditor"); + App.DoubleTap("DoubleTapEditor"); + App.EnterText("DoubleTapEditor", "Hello"); + + App.DoubleTap("DoubleTapEditor"); + App.ClearText("DoubleTapEditor"); + App.EnterText("DoubleTapEditor", "World"); + + var editorText = App.FindElement("DoubleTapEditor").GetText(); + Assert.That(editorText, Is.EqualTo("World")); + } + } +} diff --git a/src/Core/src/Handlers/Editor/EditorHandler.iOS.cs b/src/Core/src/Handlers/Editor/EditorHandler.iOS.cs index 9bebbcbb7d4a..c9871b96a4b5 100644 --- a/src/Core/src/Handlers/Editor/EditorHandler.iOS.cs +++ b/src/Core/src/Handlers/Editor/EditorHandler.iOS.cs @@ -61,16 +61,16 @@ public override Size GetDesiredSize(double widthConstraint, double heightConstra // get an exception; it doesn't know what do to with it. So instead we'll size // it to fit its current contents and use those values to replace infinite constraints - PlatformView.SizeToFit(); + var sizeThatFits = PlatformView.SizeThatFits(new CGSize(widthConstraint, heightConstraint)); if (double.IsInfinity(widthConstraint)) { - widthConstraint = PlatformView.Frame.Size.Width; + widthConstraint = sizeThatFits.Width; } if (double.IsInfinity(heightConstraint)) { - heightConstraint = PlatformView.Frame.Size.Height; + heightConstraint = sizeThatFits.Height; } }