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 page crashing when duplicating immovable blocks #3593

Merged
merged 12 commits into from
Oct 23, 2019

Conversation

miina
Copy link
Contributor

@miina miina commented Oct 22, 2019

Summary

Fixes #3467
Fixes Page Crashing when duplicating immovable blocks.

Checklist

  • My pull request is addressing an open issue (please create one otherwise).
  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

@googlebot googlebot added the cla: yes Signed the Google CLA label Oct 22, 2019
@miina miina changed the title Fixes Page Crashing when duplicating immovable blocks Fix page crashing when duplicating immovable blocks Oct 22, 2019
@@ -88,6 +91,10 @@ const PageEdit = ( {
media: mediaObject,
videoFeaturedImage: videoThumbnail,
getBlockOrder,
getImmovableBlocks: ( pageClientId ) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

You only ever invoke this with clientId - why not actually extract the list here and store it in a immovableBlocks variable? Or is there a need for a function here? It also makes the dependencies of the subsequent useEffect's more clear.

However, do remember to add clientId to the dependencies of this useSelect (it's already used here, so it's a mistake it hasn't been done already).

@swissspidy, do you know if we can add useSelect to the automatic eslint-based dependency-check? There's probably an option to add custom hooks to the validator? This hook is probably missing more than just clientId.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed in 0197f85.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@barklund Good question! I always thought it's either a limitation in the lint rule or a bug in the useSelect implementation. Looking at the code, it seems like we can just pass a regex/list of additional hooks to check against. Will whip up a quick PR to test this!

Copy link
Contributor

@barklund barklund left a comment

Choose a reason for hiding this comment

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

Make it so! 👍

@swissspidy swissspidy added this to the v1.4 milestone Oct 23, 2019
Copy link
Collaborator

@swissspidy swissspidy left a comment

Choose a reason for hiding this comment

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

Works like a charm 👍

@swissspidy swissspidy merged commit 80430f5 into develop Oct 23, 2019
@swissspidy swissspidy deleted the fix/3467-page_crash_on_duplicate branch October 23, 2019 10:37
westonruter added a commit that referenced this pull request Oct 25, 2019
…-args-debugging

* 'develop' of github.com:ampproject/amp-wp: (163 commits)
  Remove entries array test after completed.
  Update dependency core-js to v3.3.4 (#3624)
  Quick UX fixes (#3611)
  Fix most pressing RTL issues (#3558)
  Add test case for broken parent relationship
  Adapt broken test
  Throw a _doing_it_wrong() when an expected parent is not found
  Change template hierarchy query arguments to public
  Reuse data-set-focus to reliably match twentytwenty keyboard focus management
  Add tabindex attribute to modals
  Guess the role of a modal based on its classes
  Disable Code Editor (#3608)
  Update dependency postcss to v7.0.20 (#3613)
  Update dependency autoprefixer to v9.7.0 (#3614)
  Update dependency browserslist to v4.7.2 (#3612)
  Add rel=preconnect link for AMP CDN
  Fix block nav padding and margin (#3610)
  Adjust Gutenberg / WordPress requirement (#3609)
  Don't allow multiple CTA / attachment block to be pasted. (#3601)
  Fix page crashing when duplicating immovable blocks (#3593)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Signed the Google CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicating CTA / Page Attachment block crashes browser
5 participants