diff --git a/packages/block-editor/src/components/iframe/index.js b/packages/block-editor/src/components/iframe/index.js index d5821f8133e96f..ba8d6c41f06f5a 100644 --- a/packages/block-editor/src/components/iframe/index.js +++ b/packages/block-editor/src/components/iframe/index.js @@ -211,6 +211,11 @@ function useExplodedModeBackgroundStyles( isExplodedMode, deps = [] ) { copiedStylesElement.innerHTML = `:where( .is-root-container.is-exploded-mode > .wp-block ) { ${ newBackgroundStyles } }`; bodyStyleElement.innerHTML = 'body { background: gray !important; }'; + + return () => { + bodyStyleElement.textContent = ''; + copiedStylesElement.textContent = ''; + }; }, [ ...deps, isExplodedMode ] );