-
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
[Android] setSelection for Aztec wrapper #629
Conversation
Currently, it just mirrors to Aztec what the internal state vars hold. This also has the desirable effect of setting the selection to 0,0 on block split.
I noticed that sometimes when tapping on another block, say you tap between two words, the caret is initially placed at the "point of the tap", but immediately after moved to the end of the text. To reproduce the issue
(to replicate the issue you need to modify the content of the first block). |
Confirmed. Will need to fix that. |
I've revised the solution to take another route: Removed the setting of selection, and instead, added a MovementMethod that places the caret at the beginning of text when focusing the view. The Android default is to place is at the end, but in our case, placing it at the start is more appropriate. Now, we might want to place the caret at the end in some cases, and we shall make the custom MovementMethod smarter then. Ready for another pass @daniloercoli , thanks! Btw, the Gutenberg-side PR is no longer needed and will close it when we finalize this PR. |
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.
code LGTM, tried it quite a bit and it works as advertised, only thing I noticed is some lag when splitting the blocks but it doesn't seem to be a problem of this PR in particular.
I tried using large pieces of text and short words and the lag seems to be the same on both, so, doesn't seem related to content length.
Fixes #602
This PR introduces a "setSelection" functionality to the Aztec wrapper component. It is currently wired up to theRichText
component as a prop and updated every time the locally keptselectionStart
andselectionEnd
changes. See WordPress/gutenberg#13978.With this setting of selection, the caret position is set to 0 for the newly created block from the block split.This PR adds a
MovementMethod
that places the caret at the beginning of text when focusing the view. The Android default is to place is at the end, but in our case, placing it at the start is more appropriate.To test: