Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Fix for CursorPosition Property Not Applied Correctly to Entry Control #27220

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

praveenkumarkarunanithi
Copy link
Contributor

Root Cause

The native iOS UITextField control does not directly expose a cursor position property. Instead, it uses SelectedTextRange to manage the cursor's position and selection. The issue arose because, during the OnEditingBegan event (which is triggered when the entry control is focused), the UpdateSelectionLength method was called. However, within UpdateSelectionLength, there is a condition that checks whether the difference between selectedTextRange.Start and selectedTextRange.End equals entry.SelectionLength. If this condition is not met, the method does not update the SelectedTextRange (i.e., the cursor position).

Description of Change

The solution was to conditionally call UpdateCursorPosition or UpdateSelectionLength based on the SelectionLength. If SelectionLength is greater than zero, UpdateSelectionLength is called, otherwise, UpdateCursorPosition is called. This ensures that when focusing the entry control, the cursor position and selection are both applied correctly.

Issues Fixed

Fixes #19109
Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Screenshots

Before Issue Fix After Issue Fix
BeforeFix AfterFix

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jan 20, 2025
Copy link
Contributor

Hey there @praveenkumarkarunanithi! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@karthikraja-arumugam karthikraja-arumugam added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jan 22, 2025
@praveenkumarkarunanithi praveenkumarkarunanithi marked this pull request as ready for review January 22, 2025 06:58
@praveenkumarkarunanithi praveenkumarkarunanithi requested a review from a team as a code owner January 22, 2025 06:58
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).


[Test]
[Category(UITestCategories.Entry)]
public void EntryShouldApplyCursorPositionCorrectly()
Copy link
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
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?

@jsuarezruiz
Copy link
Contributor

/rebase

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-entry Entry community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/iOS 🍎 t/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The entry's cursor position is lost when transitioning to the next entry field on iOS only
3 participants