-
Notifications
You must be signed in to change notification settings - Fork 65
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
WordPress 5.8: Prevent white screen and errors on Widget Screen #1390
Conversation
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.
Works as described! I have a few non-blocking suggestions below, but feel free to ignore if they're not applicable.
@@ -42,12 +42,8 @@ | |||
const mobileToggle = document.getElementsByClassName( 'mobile-menu-toggle' ), | |||
body = document.getElementsByTagName( 'body' )[ 0 ], |
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.
Nit:
body = document.getElementsByTagName( 'body' )[ 0 ], | |
body = document.body, |
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.
Thanks! Updated in 4675b36.
const mobileOpenButton = headerContain.getElementsByClassName( 'mobile-menu-toggle' )[ 0 ], | ||
mobileCloseButton = mobileSidebar.getElementsByClassName( 'mobile-menu-toggle' )[ 0 ]; |
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.
Nit: is there any reason not to use querySelector
instead, since we're looking for single elements?
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.
None at all! 😄 updated in 4675b36.
@@ -111,6 +110,9 @@ | |||
|
|||
// Desktop menu (AKA slide-out sidebar) fallback. | |||
for ( let i = 0; i < desktopToggle.length; i++ ) { | |||
const desktopOpenButton = headerContain.getElementsByClassName( 'desktop-menu-toggle' )[ 0 ], |
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.
Nit: is there any reason not to use querySelector
instead, since we're looking for single elements?
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.
Updated in 4675b36!
Thanks @dkoo! I made the JS tweaks; the main issue there is that I'm pretty clumsy with vanilla JavaScript :) thanks for catching those! |
## [1.39.3-alpha.1](v1.39.2...v1.39.3-alpha.1) (2021-07-06) ### Bug Fixes * ads media queries ([239ff6e](239ff6e)) * correct custom fonts in block widget preview ([#1401](#1401)) ([878b6a1](878b6a1)) * figcaption rendering bug in Safari ([#1382](#1382)) ([e274499](e274499)) * improve donate block appearance for WP 5.8 ([#1398](#1398)) ([51fc4f7](51fc4f7)) * prevent white screen and errors on Widget Screen ([#1390](#1390)) ([5731581](5731581))
🎉 This PR is included in version 1.39.3-alpha.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
## [1.39.3](v1.39.2...v1.39.3) (2021-07-06) ### Bug Fixes * ads media queries ([239ff6e](239ff6e)) * correct custom fonts in block widget preview ([#1401](#1401)) ([878b6a1](878b6a1)) * figcaption rendering bug in Safari ([#1382](#1382)) ([e274499](e274499)) * improve donate block appearance for WP 5.8 ([#1398](#1398)) ([51fc4f7](51fc4f7)) * prevent white screen and errors on Widget Screen ([#1390](#1390)) ([5731581](5731581))
🎉 This PR is included in version 1.39.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
All Submissions:
Changes proposed in this Pull Request:
With WordPress 5.8's introduction of Widget Blocks,
enqueue_block_editor_assets
is now also being used on the Appearance > Widgets screen, to make sure all of the block assets are loaded. In the theme we have a number of JS files we're loading into the editor using this hook that are strictly for posts/pages: featured image placements, hiding page titles and updated dates, and article subtitles. In particular, the post-meta-toggle.js is causing an error on the Widgets screen that makes it unusable. This PR adds a check for the current screen before enqueuing any of these assets.In one related issue in the Gutenberg repo (WordPress/gutenberg#28538), there's a suggestion for possibly adding screen-specific hooks (
enqueue_block_editor_assets-$screen
) on top of what's there now; if that happens down the road, it should be easy to switch the current approach to use the new hook.In WP 5.8, some front-end scripts and styles are also being loaded into the Widgets screen; the amp-fallback.js is currently firing errors because it can't find specific HTML elements. Rather than totally blocking this script (I want to try to let WordPress do it's own thing on these updated screens as much as possible!), I increased the checks for different elements so if they're not found, the code doesn't try to run.
Notes:
Closes #1386
How to test the changes in this Pull Request:
Note: I've outlined the steps to test using two different test sites, since it saves you from having to upgrade, then downgrade, a site, but it all can be tested on one site if desired.
If you haven't already, set up a test site to run the latest WordPress 5.8 Beta (beta 4):
Select the update channel you would like this website to use:
pickBleeding Edge
; click 'Save'.Select one of the stream options below:
pickBeta/RC Only
and click 'Save'.Steps to test the PR:
npm run build
, then reload the page; confirm that it's now loading:Other information: