Skip to content

Commit 71d21f1

Browse files
authored
fix (global settings): insert the global settings style at the start instead of appendi… (#3528)
* fix: insert the global settings style at the start instead of appending after the main editor div to avoid unexpected behavior * fix: move appending of global settings style to the head
1 parent 9890d19 commit 71d21f1

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ const GlobalSettingsLoader = () => {
4545
*/
4646
useEffect( () => {
4747
const editorBody = editorDom?.closest( 'body' )
48-
if ( editorBody ) {
49-
editorBody.appendChild( globalTypographyWrapper )
50-
editorBody.appendChild( globalColorWrapper )
51-
editorBody.appendChild( globalSpacingAndBorderWrapper )
52-
editorBody.appendChild( globalButtonsAndIconsWrapper )
53-
editorBody.appendChild( globalColorSchemesWrapper )
54-
editorBody.appendChild( globalPresetControlsWrapper )
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 )
5557
}
5658
}, [ deviceType, editorDom ] )
5759

@@ -75,12 +77,12 @@ globalButtonsAndIconsWrapper?.setAttribute( 'id', 'stk-global-buttons-and-icons-
7577
globalColorSchemesWrapper?.setAttribute( 'id', 'stk-global-color-schemes-styles' )
7678
globalPresetControlsWrapper?.setAttribute( 'id', 'stk-global-preset-controls-styles' )
7779
domReady( () => {
78-
document?.body?.appendChild( globalTypographyWrapper )
79-
document?.body?.appendChild( globalColorWrapper )
80-
document?.body?.appendChild( globalSpacingAndBorderWrapper )
81-
document?.body?.appendChild( globalButtonsAndIconsWrapper )
82-
document?.body?.appendChild( globalColorSchemesWrapper )
83-
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 )
8486
createRoot( globalTypographyWrapper ).render( <GlobalTypographyStyles /> )
8587
createRoot( globalColorWrapper ).render( <GlobalColorStyles /> )
8688
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.appendChild( themeBlockSizeWrapper )
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)