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: Conditionaly apply Editor Skeleton html element styles #20245

Conversation

jorgefilipecosta
Copy link
Member

Previously editor skeleton applied styles to the HTML element unconditionally.
This PR makes sure the styles are only applied if the component is mounted.
Related: #20214 (comment)

It is important to get this in 5.4 because many blocks may have a bug where block editor styles are being enqueued without need and without this change we may be breaking the mobile experience for users with one of these blocks installed.

How has this been tested?

I verified the editor still works as expected on mobile.
I verified the styles for the new class are being loaded.

@jorgefilipecosta jorgefilipecosta added [Type] Bug An existing feature does not function as intended Backport to WP 6.8 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Feb 14, 2020
@@ -17,6 +32,7 @@ function EditorSkeleton( {
publish,
className,
} ) {
useHTMLClass( 'block-editor-editor-skeleton-html-container' );
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe more something like block-editor-editor-skeleton__html-container

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

I didn't test but this seems like a good change to me.

@jorgefilipecosta jorgefilipecosta force-pushed the fix/only-apply-html-styles-in-editor-sketelon-when-the-component-is-rendered branch from 6e19443 to b9bbeeb Compare February 14, 2020 18:07
@jorgefilipecosta jorgefilipecosta merged commit ecd3b45 into master Feb 14, 2020
@jorgefilipecosta jorgefilipecosta deleted the fix/only-apply-html-styles-in-editor-sketelon-when-the-component-is-rendered branch February 14, 2020 18:44
@github-actions github-actions bot added this to the Gutenberg 7.6 milestone Feb 14, 2020
@jorgefilipecosta jorgefilipecosta removed the Backport to WP 6.8 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Feb 18, 2020
function useHTMLClass( className ) {
useEffect( () => {
const element =
document && document.querySelector( `html:not(.${ className }` );
Copy link
Member

@aduth aduth Feb 27, 2020

Choose a reason for hiding this comment

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

Typo:

Suggested change
document && document.querySelector( `html:not(.${ className }` );
document && document.querySelector( `html:not(.${ className })` );

Causing: #20504

Edit: Fix: #20507

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants