-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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 TextInput maxLength when insert characters at begin #23472
Conversation
@rigdern Adam, what do you think? |
@shergin I'm not familiar with this code. I read over the PR but it's unclear to me what flaw in the code is causing the symptom and why this delta fixes it. |
@zhongwuzw Can you share that the issue is you're seeing and how to repro it? Like @rigdern said, it's not clear to me what the issue is and how this fixes it - if you're seeing an inconsistency here, then it seems like predictedText already got out of sync with the backing textinput view. I think this change may make sense regardless, but I just want to take a look and see where things are going wrong. |
@ejanzer Hi, I borrowed the repro from #21639 :
|
Based on repro example, when we insert |
Oh I see, the problem is if you set an initial value from JS then @zhongwuzw would you mind also cleaning up the other places in this file where we set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment about previousText - also please clean up the other places where we set _predictedText
if they're no longer needed:
if (range.location + range.length > _predictedText.length) { |
and
_predictedText = backedTextInputView.attributedText.string; |
@@ -338,11 +338,7 @@ - (BOOL)textInputShouldChangeTextInRange:(NSRange)range replacementText:(NSStrin | |||
|
|||
NSString *previousText = [_predictedText substringWithRange:range] ?: @""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably move this above here so that previousText is set correctly.
@ejanzer Hey, I clean up the code, please continue to review it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ejanzer has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ejanzer has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This pull request was successfully merged by @zhongwuzw in 1741593. When will my fix make it into a release? | Upcoming Releases |
Summary: Fixes #21639 , seems we tried to fix this before, please see related `PR` like [D10392176](36507e4), #18627, but they don't solve it totally. [iOS] [Fixed] - Fix TextInput maxLength when insert characters at begin Pull Request resolved: #23472 Reviewed By: mmmulani Differential Revision: D14366406 Pulled By: ejanzer fbshipit-source-id: fc983810703997b48824f84f2f9198984afba9cd
Summary
Fixes #21639 , seems we tried to fix this before, please see related
PR
like D10392176, #18627, but they don't solve it totally.Changelog
[iOS] [Fixed] - Fix TextInput maxLength when insert characters at begin
Test Plan
From the git log, we faced some issues, like Backspace event, we need to ensure no regression happened, issues like #21639 #18627 should be fixed.