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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/block-editor/src/components/editor-skeleton/index.js
Expand Up @@ -6,9 +6,24 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { useEffect } from '@wordpress/element';
import { navigateRegions } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

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

if ( ! element ) {
return;
}
element.classList.toggle( className );
return () => {
element.classList.toggle( className );
};
}, [ className ] );
}

function EditorSkeleton( {
footer,
header,
Expand All @@ -17,6 +32,7 @@ function EditorSkeleton( {
publish,
className,
} ) {
useHTMLClass( 'block-editor-editor-skeleton__html-container' );
return (
<div
className={ classnames(
Expand Down
@@ -1,6 +1,6 @@
// On Mobile devices, swiping the HTML element should not scroll.
// By making it fixed, we prevent that.
html {
html.block-editor-editor-skeleton__html-container {
position: fixed;
width: 100%;

Expand Down