Skip to content

[iOS, Mac] Fix for CursorPosition not updating when typing into Entry control #30505

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SyedAbdulAzeemSF4852
Copy link
Contributor

@SyedAbdulAzeemSF4852 SyedAbdulAzeemSF4852 commented Jul 9, 2025

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details

  • When typing into Entry control on iOS, the CursorPosition property is not updated.

Root Cause

  • OnEditingChanged was updating the text but not the cursor position, causing the virtual view's cursor position to become out of sync with the platform view during typing.

Description of Change

  • Introduced a new method UpdateCursorPosition in the ITextInputExtensions class to update the cursor position if it differs from the current value.
  • Updated EntryHandler.iOS to call UpdateCursorPosition during the OnEditingChanged event, ensuring the cursor position stays in sync with text changes.

Issues Fixed

Fixes #20911

Validated the behaviour in the following platforms

  • Windows
  • Android
  • iOS
  • Mac

Output

Before After
Before.mov
After.mov

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

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

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jul 9, 2025
@SyedAbdulAzeemSF4852 SyedAbdulAzeemSF4852 changed the title [iOS, Mac] Fix for Entry not updating CursorPosition on TextChanged Evemnt [iOS, Mac] Fix for CursorPosition not updating when typing into Entry control Jul 9, 2025
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@SyedAbdulAzeemSF4852 SyedAbdulAzeemSF4852 marked this pull request as ready for review July 10, 2025 11:22
@Copilot Copilot AI review requested due to automatic review settings July 10, 2025 11:22
@SyedAbdulAzeemSF4852 SyedAbdulAzeemSF4852 requested a review from a team as a code owner July 10, 2025 11:22
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures the CursorPosition on the Entry control stays in sync when typing on iOS (and Mac Catalyst) by calling a new extension method and validating the behavior with a UI test.

  • Added an UpdateCursorPosition extension in ITextInputExtensions to update the cursor when it changes.
  • Updated EntryHandler.iOS to invoke UpdateCursorPosition during OnEditingChanged.
  • Introduced a HostApp page and a shared UI test (Issue20911) to verify that typing into an Entry updates its cursor position.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/Core/src/Handlers/Entry/EntryHandler.iOS.cs Invoke UpdateCursorPosition after updating text in OnEditingChanged
src/Core/src/Core/Extensions/ITextInputExtensions.cs Add UpdateCursorPosition extension method to sync cursor position
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue20911.cs Add UI test to enter text and verify the cursor position
src/Controls/tests/TestCases.HostApp/Issues/Issue20911.cs Create HostApp page with an Entry, status Label, and validation Button
Comments suppressed due to low confidence (2)

src/Controls/tests/TestCases.HostApp/Issues/Issue20911.cs:7

  • [nitpick] The variable name cursorPositonStatusLabel has a typo. Consider renaming it to cursorPositionStatusLabel for consistency and clarity.
	Label cursorPositonStatusLabel;

src/Core/src/Core/Extensions/ITextInputExtensions.cs:45

  • Consider adding unit tests for UpdateCursorPosition to verify that it correctly updates the CursorPosition when it differs and does nothing when positions are equal.
		internal static void UpdateCursorPosition(this ITextInput textInput, int cursorPosition)

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 platform/macos macOS / Mac Catalyst
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Entry control CursorPosition does not update on TextChanged event [iOS Maui 8.0.7]
2 participants