Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue19109.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
namespace Maui.Controls.Sample.Issues
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 19109, "CursorPosition Property Not Applied Correctly to Entry Control on iOS Platform", PlatformAffected.iOS)]
public partial class Issue19109: ContentPage
{
Entry entry;
public Issue19109()
{
entry = new Entry
{
Text = "Entry 123",
CursorPosition = 5,
Placeholder = "Focus this entry to check if the cursor position is set correctly.",
ReturnType = ReturnType.Next,
AutomationId = "EntryControl"
};

var button = new Button
{
Text = "Focus Entry",
AutomationId = "FocusButton"
};

var label = new Label
{
Text = "Cursor Position: 5",
FontSize = 16,
TextColor = Colors.Black,
HorizontalOptions = LayoutOptions.Center
};

button.Clicked += (sender, e) =>
{
entry.Focus();
};

Content = new StackLayout
{
Children = { entry, button, label },
Padding = new Thickness(20),
Spacing = 10
};

}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
internal class Issue19109 : _IssuesUITest
{
public Issue19109(TestDevice device) : base(device) { }

public override string Issue => "CursorPosition Property Not Applied Correctly to Entry Control on iOS Platform";

[Test]
[Category(UITestCategories.Entry)]
public void EntryShouldApplyCursorPositionCorrectly()
Comment thread
jsuarezruiz marked this conversation as resolved.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build is failing because the cursor is blinking, not guaranteed will appear in the snapshot: EntryShouldApplyCursorPositionCorrectly
After merge #27277 just update the test to remove the cursor from the snapshots.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsuarezruiz , Thanks for the feedback. The UI test is crucial for verifying that the cursor position is correctly applied to the Entry control, which is central to the fix. Removing the cursor from the snapshot could prevent us from validating this functionality accurately. How can we handle this?

{
App.WaitForElement("EntryControl");
App.WaitForElement("FocusButton");
App.Tap("FocusButton");
VerifyScreenshot();
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion src/Core/src/Handlers/Entry/EntryHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,12 @@ void OnEditingBegan(object? sender, EventArgs e)
{
if (sender is MauiTextField platformView && VirtualView is IEntry virtualView)
{
platformView.UpdateSelectionLength(virtualView);
if (virtualView.SelectionLength > 0) {
platformView.UpdateSelectionLength(virtualView);
}
else {
platformView.UpdateCursorPosition(virtualView);
}
virtualView.IsFocused = true;
}
}
Expand Down
Loading