-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add MaxLength limit to cursor position updates #15970
Conversation
Hey there @cat0363! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
who should review this PR? |
I have the same issue :/ |
+1 |
/rebase |
Hey @cat0363 I was just looking into this one, it seems like some work was done in this area. Could you confirm that this fix is still needed? And if you think it is, could you rebase it? Thanks! |
Hi @cat0363. We have added the "s/pr-needs-author-input" label to this issue, which indicates that we have an open question/action for you before we can take further action. This PRwill be closed automatically in 14 days if we do not hear back from you by then - please feel free to re-open it if you come back to this PR after that time. |
@jfversluis , Thank you for the good news. |
Hehehe no worries my friend, I think we should be apologising to you for the delay on this PR 😉 Thanks for your efforts here and confirming this is fixed! Looking forward to your future work on this project! |
Description of Change
An exception will occur on Android and iOS if you bind a string that exceeds the value specified in the MaxLength property to the Text property of Entry and Editor. In this PR, we will add consideration of the MaxLength property to cursor position updates.
On iOS, calling the GetTextRange method inside the SetTextRange method of the TextInputExtensions class caused an ArgumentNullException.
[src\Core\src\Platform\iOS\TextInputExtensions.cs]
This is because the startPosition and endPosition passed to the GetTextRange method are null. This is because null is returned if you specify an index that exceeds MaxLength in the offset of the GetPosition method. This offset should be set considering MaxLength.
I fixed it as follows.
[src\Core\src\Platform\iOS\TextInputExtensions.cs]
[src\Controls\src\Core\Platform\iOS\Extensions\TextExtensions.cs]
On Android, calling the SetSelection method inside the UpdateText method of the EditTextExtensions class caused an IndexOutOfBoundsException.
[src\Controls\src\Core\Platform\Android\Extensions\EditTextExtensions.cs]
This is because an index exceeding the MaxLength property was specified as an argument when the SetSelection method was called.
I fixed it as follows.
[src\Controls\src\Core\Platform\Android\Extensions\EditTextExtensions.cs]
On Windows, the exception is not thrown, but updating the cursor position requires a similar fix.
[src\Controls\src\Core\Platform\Windows\Extensions\TextBoxExtensions.cs]
However, there is no problem with the Windows TextBox Select method even if you specify an Index that exceeds MaxLength, so there is no problem even if you do not include a guard condition.
In addition to the solution in PR #7371, the MaxLength property should be considered.
This PR targets iOS, Android, and Windows, which were targeted for fixes in PR #7371.
Issues Fixed
Fixes #15937