Skip to content

Commit

Permalink
Fixed the double tap editor freeze issue and added test cases (#26203)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
1 parent 66982c3 commit e72f6ad
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
32 changes: 32 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue25975.cs
Original file line number Diff line number Diff line change
@@ -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;

}
}
}
Original file line number Diff line number Diff line change
@@ -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"));
}
}
}
6 changes: 3 additions & 3 deletions src/Core/src/Handlers/Editor/EditorHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit e72f6ad

Please sign in to comment.