-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 block inserter WSOD when an empty reusable block exists #26484
Conversation
Size Change: +4 B (0%) Total Size: 1.2 MB
ℹ️ View Unchanged
|
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.
Verified that this fixes the issue. 👍
fb126e6
to
ba1841b
Compare
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.
I can also confirm that opening an inserter after creating an empty reusable block behaves as expected. I double checked the fix in multiple browsers for safe measure (Firefox, Chrome, Safari, IE11, Edge)
This tests well 👍🏻 |
Should this fix be backported to WordPress 5.6? (@tellthemachines just making you aware of this one). I'll label it up and add it the board just to be safe. |
Potentially also fixes #26381 edit: now confirmed by the reporter, so I've linked this PR as the one that fixes it. |
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.
Can confirm it fixes the issue, and the change makes sense 👍
Rebasing the PR should hopefully get the tests to pass, as they've been a bit more reliable today.
ba1841b
to
c10c09c
Compare
I've rebased 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.
I'm digging in a bit to try to better understand this. The changes happened in #25859.
- 8bf36e2 changes the data shape. It removes some pre-processing. Here it is
return parse( reusableBlock.content.raw );
- d5ac446 adds the fallback
return parse( reusableBlock.content.raw || reusableBlock.content );
. What motivated this change? - Issue [@wordpress/core-data] getEntityRecords and saveEntityRecord don't sync data correctly #22127 is mentioned, but it's not clear to me how it's related. The shape of the data seems to have changed.
This changes seems to be an adequate fix although I'd like to understand what's going on. As far as I can tell we'd like to expect content.raw
is a string and use that if so, but we don't expect it to be inconsistent for reasons that are unclear to me. CC: @adamziel in case you recall any details.
I tried re-running the tests a couple of times, but couldn't get them to pass. The failing tests are also failing in |
* nest content styles in container for higher specificity (#26487) * Reusable Blocks: Make the number retrieved from the API unlimited (#26486) * Make the number of reusable blocks returned from the API unlimited This is to fix #26352. Having no limit seems like it could be risky, but there are a number of other places in the codebase where all entities are returned in one call to the API, including categories, which could return a similar amount of data to this. * Remove unnecessary quotes to fix lint error. * Fix block inserter WSOD when an empty reusable block exists (#26484) * Latest Posts: Bring back classname on post list (#26477) * [Heading Block] Fix double alignment controls in toolbar (#26492) * fix heading alignments * add proper supports in deprecation * update all previous deprecations * regenerate fixtures for heading * change migration call * remove previous className + revert saves * Revert "regenerate fixtures for heading" This reverts commit 27af8c3. * change fixtures * create new fixtures + fix deprecation save * address review feedback * URLInput: Use debounce() instead of throttle() (#26529) Wait until the user finishes typing before sending an AJAX request. This ensures that there isn't an AJAX request sent every 200 ms while the user is typing. * Fix single column block display for smaller screens. (#26438) If there is only one column, don't force a 50% flex-basis for small screens. * Fix incorrectly pluralised strings (#26565) * Change block mover label i18n * Update remove block i18n * Ensure footer remains position fixed when navigating regions (#26533) * Update package-lock file to ensure static analysis task passes (#26528) * Removes extra fullstop (#26586) Co-authored-by: Addison Stavlo <Stavz01@gmail.com> Co-authored-by: Paul Bunkham <paul@dobit.co.uk> Co-authored-by: Noah Allen <noahtallen@gmail.com> Co-authored-by: Kelly Dwan <ryelle@users.noreply.github.com> Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com> Co-authored-by: Robert Anderson <robert@noisysocks.com> Co-authored-by: Aaron D. Campbell <aaron@AaronDCampbell.com> Co-authored-by: Daniel Richards <daniel.richards@automattic.com> Co-authored-by: Tammie Lister <tammie@automattic.com>
Problem: when a user has an empty reusable block (e.g. the post content is an empty string), the block inserter selector passes the content object instead of the content string into the parser. This causes an editor WSOD.
The fix is to check for a string instead of a truthy value. The old truthy check doesn't work for empty strings because empty strings are falsey.
This error happens on any post, even if it does not use reusabel blocks. This is because the inserter always attempts to load the reusable blocks so the user can preview them.
To test:
Previous behavior:
6. The editor crashes to a WSOD.
Fixed behavior:
6. The inserter opens.
closes #26485