Skip to content
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

Point to gutenberg hash with list block spaces crash fix #885

Merged
merged 5 commits into from
Apr 17, 2019

Conversation

hypest
Copy link
Contributor

@hypest hypest commented Apr 17, 2019

Fixes #871

Gutenberg side PR: WordPress/gutenberg#15021

This PR brings in the fix, which is only on source code on the Gutenberg repo.

The internal representation of rich-text in Aztec and the format-lib are not fully compatible or in-sync and we also use html to establish the communication between the two. That can lead to cases like the issue linked, where Aztec will do some trimming to remove spaces that are unimportant for html rendering, but format-lib won't so, making the caret positioning logic to get out of sync.

This fix will try to detect when such spaces will be removed and avoid telling Aztec where to put the caret and hope for the best 🤞.

This fix is not "perfect" though. It only touches the Android side (iOS seems to handle the caret setting OK) and will also lead to the text entered by the user being mutated since the spaces will get trimmed by Aztec.

To test A

  1. Begin editing new list
  2. Add two spaces, then any letter and then press Enter
  3. The list should create a new list item and the spaces in the item above it will be trimmed

To test B

  1. Begin editing new list
  2. Add three spaces and press Enter
  3. The list should create a new list item and the spaces in the item above it will be trimmed

To test C

  1. Begin editing new list
  2. Add any letter, add three spaces (second space creates a period) and press Enter
  3. The list should create a new list item and the spaces in the item above it will be trimmed

Copy link
Contributor

@marecar3 marecar3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@hypest hypest merged commit 3f0330e into develop Apr 17, 2019
@hypest hypest deleted the issue/871-list-crashes-with-extra-spaces-android branch April 17, 2019 22:05
@mkevins
Copy link
Contributor

mkevins commented Apr 19, 2019

I tested cases A, B, and C on Android emulator, and observed the results described. I noticed, though, that the period-creation after two spaces (described in test case C) did not always seem to happen. For example, if I:

  1. Tap the + button, and create a new list block.
  2. Type the letter 'T', followed by 3 spaces.

I do not observe the creation of the period. But if I:

  1. Tap the + button, and create a new list block.
  2. Type the letter 'T', followed by 1 space.
  3. Type [Backspace].
  4. Type 3 spaces.

I do observe the period being created.

In any case, the text in the list item is trimmed. I suspect that the creation of the period may have something to do with the keyboard (AOSP built in emulator keyboard, in this case), and may be unrelated to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

List crashes with extra spaces
3 participants