-
Notifications
You must be signed in to change notification settings - Fork 58
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
[FIX] Rich Text loop when autocompleting text on iOS #1702
Conversation
Yes we do @mchowning, we are trying both approaches :) |
I realized that this PR is breaking auto-scroll on iOS, because keyboard-aware-scroll-view trusts TextInputState to find out the currently focused TextInput and then it adjusts the scroll position accordingly. This is PR is making the global TextInputState not trustable anymore so it can have lots of other side effects as well. |
Yeah, right we need the The paint point is that there is no method My point is I think there is no reason to call Let's imagine this kind of scenario:
And the loop starts. It's because we call I added this function to
Good news is that there are actually functions |
Those new methods in react-native are nice and will likely make this more robust, but I think that today's problem lies in here:
A change on selection shouldn't trigger a change in focus. This kind of makes sense on the web since selection is global across the whole document, but on native, selection is specific to each view, so that's making things confusing:
We still want to receive the first |
Make sense. I reverted those changes related to the |
react-native-aztec/src/AztecView.js
Outdated
@@ -34,6 +34,14 @@ class AztecView extends React.Component { | |||
...TextViewPropTypes, // include the default view properties | |||
} | |||
|
|||
componentDidMount() { | |||
TextInputState.registerInput(ReactNative.findNodeHandle(this)) |
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.
Could you explain a bit how this registerInput/unregisterInput works and how do they contribute to the solution?
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.
TBH I don't think that they are needed in that solution but I added it because I realized that we don't do that at this moment. They add or remove fieldID
to/from Set
of inputs in TextInputState
https://github.com/facebook/react-native/blob/master/Libraries/Components/TextInput/TextInputState.js#L85-L95
W/o this the false
will be always returned when isTextInput
is called with Aztec field ID
https://github.com/facebook/react-native/blob/master/Libraries/Components/TextInput/TextInputState.js#L93-L95
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.
This sounds really nice but I am a bit afraid about consequences. We don't know who is calling isTextInput
and what could be done differently if it turns true this time. So I'd avoid adding it unless we have enough context. I am just trying to be extra cautious since this has been a pretty fragile component so far.
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.
Ok, I understand your worries so I will remove it then :)
the new solution looks a lot better but I come across with a keyboard close button issue. It is not working in certain scenarios:
|
But the issues related to focus loop on auto correct is fixed. I tested both cases: text from autocorrection has the same length as written text:
text from autocorrection has a different length as written text
|
The issue about keyboard close button is fixed! 🎉 |
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.
LGTM!
Tested with steps here on both WPAndroid and WPiOS.
a717073
to
3d3fb92
Compare
Fixes #
Gutenberg PR: WordPress/gutenberg#19240
Fixes: #1696
In this PR I created a local variable for focus state instead of using
TextInputState
, thanks to that we do not callfocus()
inonFocus
which was a bit weird. I also pass the latest native value toonBlur
event to update JS value if that is not correct.PR submission checklist:
RELEASE-NOTES.txt
if necessary.