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

Fix crash on mobile when pasting formatted text. #18740

Closed
wants to merge 1 commit into from

Conversation

cameronvoell
Copy link
Member

@cameronvoell cameronvoell commented Nov 26, 2019

Description

Adding a check for undefined node.parentElement.closest which was caught in this failing test causing a crash on mobile when pasting formatted (bold) text

How has this been tested?

I tested on gutenberg web, and was not able to reproduce the error that I was seeing on mobile. I tested that the check for undefined fixes the pasting of formatted text crash on mobile.

See Gutenberg mobile PR is now showing a pass on the test for pasting formatted text: wordpress-mobile/gutenberg-mobile#1617

Screenshots

Types of changes

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 marked this pull request as ready for review November 26, 2019 04:42
@cameronvoell cameronvoell requested review from etoledom and removed request for youknowriad and gziolo November 26, 2019 04:42
@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 Nov 26, 2019
Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

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

Looks good and safe to me! Thank you @cameronvoell for figuring this out.

Just to be sure, let's wait for @ellatrix 's 👀 before merging.

@ellatrix
Copy link
Member

@@ -42,7 +42,7 @@ export default function( node ) {
}

// Ignore pre content.
if ( node.parentElement.closest( 'pre' ) ) {
if ( node.parentElement.closest && node.parentElement.closest( 'pre' ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

What is node.parentElement if not an element node or null? Could you add a test case or leave a comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ellatrix - Do you mean a comment explaining the reason?
For what I understand, this check prevents a crash on Native Android. Would that be good for a comment?

Copy link
Member

Choose a reason for hiding this comment

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

I would like to know the cause of the crash. What is node.parentElement, if not an Element? This line important for paste. We don't want it to be skipped, even for mobile.

https://developer.mozilla.org/en-US/docs/Web/API/Element/closest

Copy link
Contributor

Choose a reason for hiding this comment

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

There is this new PR that we hope will solve the root cause:
wordpress-mobile/gutenberg-mobile#1626

If that's the case, this PR won't be needed anymore 🙏

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

@hypest
Copy link
Contributor

hypest commented Nov 28, 2019

I don't see anything at https://app.circleci.com/jobs/github/wordpress-mobile/gutenberg-mobile/17951/tests.

You're right @ellatrix . Unfortunately in this case, the failing tests are in the e2e native tests and those are not in the Gutenberg repo yet. Just for adding context, the e2e tests involve testing on real devices/emulators and we are not ready yet to include those in Gutenberg's repo.

In the meantime, wordpress-mobile/gutenberg-mobile#1626 got merged and fixes the issue via a different route so, I think it's OK to close this PR now @cameronvoell .

@youknowriad youknowriad deleted the rnmobile/fix-crash-pasting-styled-text branch December 3, 2019 08:56
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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants