Skip to content

Commit 03e56da

Browse files
committed
fix: insert the global settings style at the start instead of appending after the main editor div to avoid unexpected behavior
1 parent 9890d19 commit 03e56da

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,15 @@ const GlobalSettingsLoader = () => {
4646
useEffect( () => {
4747
const editorBody = editorDom?.closest( 'body' )
4848
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 )
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 )
5558
}
5659
}, [ deviceType, editorDom ] )
5760

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const ThemeBlockSize = () => {
2828
useEffect( () => {
2929
const editorBody = editorDom?.closest( 'body' )
3030
if ( editorBody ) {
31-
editorBody.appendChild( themeBlockSizeWrapper )
31+
editorBody.insertBefore( themeBlockSizeWrapper, editorBody.firstChild )
3232
}
3333
}, [ deviceType, editorDom ] )
3434

0 commit comments

Comments
 (0)