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

[RNMobile] - test break tags removal #19976

Closed
wants to merge 2 commits into from

Conversation

cameronvoell
Copy link
Member

@cameronvoell cameronvoell commented Jan 31, 2020

Description

Fixes part of wordpress-mobile/gutenberg-mobile#1543 addressing some comments from here: #18138 (review)

This changes adds more visibility into selection adjustments that we are making in gutenberg mobile code to ensure compatibility with react-native-aztec.

The code tested in this change is related to addressing a crash that was surfaced by the WordPressAndroid app which is using this code: wordpress-mobile/WordPress-Android#9832

How has this been tested?

Tested using steps from the PR that originally added this code:

  1. Create a post on Gutenberg web with a para block that ends with one or more empty line(s) (Shift+Enter)
  2. Open this new post in GB mobile
  3. Tap on the Plus symbol to add a new block below the para
  4. Put the focus into this new block and taps on Backspace to merge this new block with the one above.
  5. It should not crash, and the 2 blocks merged, with the caret at the end of the block

Also you can run the new tests using the following:
yarn test gutenberg/packages/rich-text/src/component/test/index.native.js

Types of changes

This change is only introducing some new unit tests and a small refactor to accommodate those tests.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR. .

@cameronvoell cameronvoell changed the title Rnmobile - test break tags removal [RNMobile] - test break tags removal Jan 31, 2020
@cameronvoell cameronvoell marked this pull request as ready for review January 31, 2020 02:54
Copy link
Contributor

@mchowning mchowning left a comment

Choose a reason for hiding this comment

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

Nice job @cameronvoell ! Those tests make the intention here sooo much clearer imo! 🙇

I left a couple of minor comments, but they're really just suggestions/thoughts. This looks good to me! 🎉

expect( richText.countBreaksBeforeParagraphTag( html ) ).toBe( 0 );
} );

it( 'Counts zero breaks when no break is not directly in front of ending paragraph tag', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we have an unintended double negative here ("no break is not"). Maybe something like, "Count zero breaks when breaks do not directly precede an ending paragraph tag"?

@@ -649,6 +650,16 @@ export class RichText extends Component {
return value;
}

countBreaksBeforeParagraphTag( html ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about specifying that it's an end tag: countBreaksBeforeParagraphEndTag? I don't feel strongly about this.

}
selection = { start: newSelectionStart, end: newSelectionEnd };
Copy link
Contributor

Choose a reason for hiding this comment

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

I really like how you have the regex broken out into a separate function with tests (those tests you added are 😻).

I would have probably taken this a bit further and extracted out all or most of 707-718 into some kind of pure 'calculateSelectionBasedOnAztecModifications( html, { originalStartSelection, originalEndSelection } )function that took in the html and old selection and output the updated selection for the anticipated Aztec-output text. We would then end up with just having something like this in therender` method:

...
} else {
    selection = calculateSelectionBasedOnAztecModifications( html, selection );
}

With that said, I think extracting that out at this point falls well within the realm of personal preference, and the changes you have made are already a really great improvement, so feel free to leave this as-is if you prefer. 😄

@cameronvoell cameronvoell added the Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) label May 12, 2020
@hypest
Copy link
Contributor

hypest commented Oct 2, 2020

This PR looks like it's stale. Can you circle back @cameronvoell and either land it or close it? Thanks!

@gziolo gziolo added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Nov 28, 2020
@gziolo
Copy link
Member

gziolo commented Nov 28, 2020

This PR looks to be abandoned, I marked it as stale. If it won’t get updated in the next few weeks it might get closed.

It was approved with minor comments so it seems beneficial to rebase it and take to the finish line.

Base automatically changed from master to trunk March 1, 2021 15:43
@Thelmachido
Copy link

@cameronvoell This issue was marked as stale in 2020 it has seen no movement since then, closing this PR for now. If anyone feels it should still be looked at, please add a comment and I can take another look. Thanks!

@Thelmachido Thelmachido closed this Sep 2, 2022
@gziolo gziolo deleted the rnmobile/test-break-tag-removal branch September 2, 2022 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants