Skip to content

Commit b361998

Browse files
Fix: Conditionaly apply Editor Skeleton html element styles (#20245)
1 parent 786cb6a commit b361998

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

packages/block-editor/src/components/editor-skeleton/index.js

+16
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,24 @@ import classnames from 'classnames';
66
/**
77
* WordPress dependencies
88
*/
9+
import { useEffect } from '@wordpress/element';
910
import { navigateRegions } from '@wordpress/components';
1011
import { __ } from '@wordpress/i18n';
1112

13+
function useHTMLClass( className ) {
14+
useEffect( () => {
15+
const element =
16+
document && document.querySelector( `html:not(.${ className }` );
17+
if ( ! element ) {
18+
return;
19+
}
20+
element.classList.toggle( className );
21+
return () => {
22+
element.classList.toggle( className );
23+
};
24+
}, [ className ] );
25+
}
26+
1227
function EditorSkeleton( {
1328
footer,
1429
header,
@@ -17,6 +32,7 @@ function EditorSkeleton( {
1732
publish,
1833
className,
1934
} ) {
35+
useHTMLClass( 'block-editor-editor-skeleton__html-container' );
2036
return (
2137
<div
2238
className={ classnames(

packages/block-editor/src/components/editor-skeleton/style.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// On Mobile devices, swiping the HTML element should not scroll.
22
// By making it fixed, we prevent that.
3-
html {
3+
html.block-editor-editor-skeleton__html-container {
44
position: fixed;
55
width: 100%;
66

0 commit comments

Comments
 (0)