[FIX] Rich Text loop when autocompleting text on iOS#1702
[FIX] Rich Text loop when autocompleting text on iOS#1702dratwas merged 13 commits intorelease/1.20.0from
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
| } | ||
|
|
||
| componentDidMount() { | ||
| TextInputState.registerInput(ReactNative.findNodeHandle(this)) |
There was a problem hiding this comment.
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.
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.
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.
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! 🎉 |
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()inonFocuswhich was a bit weird. I also pass the latest native value toonBlurevent to update JS value if that is not correct.PR submission checklist:
RELEASE-NOTES.txtif necessary.