-
Notifications
You must be signed in to change notification settings - Fork 4.7k
[RNMobile] Partial fix splitting & merging Paragraph/Heading issue in ReactAztec Android #29654
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
Conversation
|
@cameronvoell @geriux I am just sharing this WIP PR, I used to explore this issue. Let me know if the fix I am trying gives you any ideas. |
|
Size Change: 0 B Total Size: 1.4 MB ℹ️ View Unchanged
|
|
FWIW, I'm having a look at the issue as well. I have the impression that the selection change event that gets received after the |
|
Closing this PR since #29683 has a more optimal solution. |
Fixes #29478
Gutenberg Mobile wordpress-mobile/gutenberg-mobile#3233
Description
This solution resolves a bug with the splitting/merging behavior of the Paragraph/Heading block.
There are currently two mechanisms for processing enter events within the
ReactAztecTextcomponent.KeyListeneris utilized to listen to key presses that are triggered from a physical keyboard. - The editor behaves as expected.EnterPressedWatcherthat observes text changes that occur as a result of the soft keyboard. - The editor does not behave as expected.Currently, within the editor, once the user moves the cursor within the content a selection change event is triggered as the
selectionStartandselectionEndproperties are modified and the content changes are processed as a result.The Problem
There are several events are created when the editor notifies listeners of
onEnter,onBackspace,onPasteetc. actions.In the case of this bug, the editor has created two events instead of one. First the
onEnterevent is triggered and then thepropagateSelectionChanges. I think then when thepropagateSelectionChangesevent is triggered, it is overwriting the content that was appropriately processed by theonEnterevent, thus putting theRichTextcomponent in an inconsistent state.The Partial Solution
The solution I came up with, was to dedicate a flag specifically to toggling the
propagateSelectionChangesduring the execution of theonEnterfunction. I could have utilized theshouldHandleOnSelectionChangebut I decided not to as I wanted to use a flag that would be specific to the issue in case it can be refactored later.During testing, I sometimes end up with the bug. I think it's as a result of a selection change bypassing the flag. This will require more investigation. I might try disabling the listener depending on if text watchers are processed before selection change events.
How has this been tested?
Screenshots
editor.mp4
Checklist: