Skip to content

Commit 7b688dc

Browse files
committed
fix: move appending of global settings style to the head
1 parent 03e56da commit 7b688dc

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

src/plugins/global-settings/editor-loader.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,15 @@ const GlobalSettingsLoader = () => {
4545
*/
4646
useEffect( () => {
4747
const editorBody = editorDom?.closest( 'body' )
48-
if ( editorBody ) {
49-
// No need to check for firstChild, since there will always be at least one
50-
// e.g. the post title wrapper and the actual root container.
51-
const firstChild = editorBody.firstChild
52-
editorBody.insertBefore( globalTypographyWrapper, firstChild )
53-
editorBody.insertBefore( globalColorWrapper, firstChild )
54-
editorBody.insertBefore( globalSpacingAndBorderWrapper, firstChild )
55-
editorBody.insertBefore( globalButtonsAndIconsWrapper, firstChild )
56-
editorBody.insertBefore( globalColorSchemesWrapper, firstChild )
57-
editorBody.insertBefore( globalPresetControlsWrapper, firstChild )
48+
const editorHead = editorBody?.ownerDocument?.head
49+
50+
if ( editorHead ) {
51+
editorHead.appendChild( globalTypographyWrapper )
52+
editorHead.appendChild( globalColorWrapper )
53+
editorHead.appendChild( globalSpacingAndBorderWrapper )
54+
editorHead.appendChild( globalButtonsAndIconsWrapper )
55+
editorHead.appendChild( globalColorSchemesWrapper )
56+
editorHead.appendChild( globalPresetControlsWrapper )
5857
}
5958
}, [ deviceType, editorDom ] )
6059

@@ -78,12 +77,12 @@ globalButtonsAndIconsWrapper?.setAttribute( 'id', 'stk-global-buttons-and-icons-
7877
globalColorSchemesWrapper?.setAttribute( 'id', 'stk-global-color-schemes-styles' )
7978
globalPresetControlsWrapper?.setAttribute( 'id', 'stk-global-preset-controls-styles' )
8079
domReady( () => {
81-
document?.body?.appendChild( globalTypographyWrapper )
82-
document?.body?.appendChild( globalColorWrapper )
83-
document?.body?.appendChild( globalSpacingAndBorderWrapper )
84-
document?.body?.appendChild( globalButtonsAndIconsWrapper )
85-
document?.body?.appendChild( globalColorSchemesWrapper )
86-
document?.body?.appendChild( globalPresetControlsWrapper )
80+
document?.head?.appendChild( globalTypographyWrapper )
81+
document?.head?.appendChild( globalColorWrapper )
82+
document?.head?.appendChild( globalSpacingAndBorderWrapper )
83+
document?.head?.appendChild( globalButtonsAndIconsWrapper )
84+
document?.head?.appendChild( globalColorSchemesWrapper )
85+
document?.head?.appendChild( globalPresetControlsWrapper )
8786
createRoot( globalTypographyWrapper ).render( <GlobalTypographyStyles /> )
8887
createRoot( globalColorWrapper ).render( <GlobalColorStyles /> )
8988
createRoot( globalSpacingAndBorderWrapper ).render( <GlobalSpacingAndBordersStyles /> )

src/plugins/theme-block-size/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ export const ThemeBlockSize = () => {
2727

2828
useEffect( () => {
2929
const editorBody = editorDom?.closest( 'body' )
30-
if ( editorBody ) {
31-
editorBody.insertBefore( themeBlockSizeWrapper, editorBody.firstChild )
30+
const editorHead = editorBody?.ownerDocument?.head
31+
32+
if ( editorHead ) {
33+
editorHead.appendChild( themeBlockSizeWrapper )
3234
}
3335
}, [ deviceType, editorDom ] )
3436

@@ -50,6 +52,6 @@ if ( themeBlockSizeWrapper ) {
5052
}
5153

5254
domReady( () => {
53-
document?.body?.appendChild( themeBlockSizeWrapper )
55+
document?.head?.appendChild( themeBlockSizeWrapper )
5456
createRoot( themeBlockSizeWrapper ).render( <ThemeBlockSize /> )
5557
} )

0 commit comments

Comments
 (0)