Skip to content

Commit

Permalink
Avoid errors in Dimension visualizers when switching between iframed …
Browse files Browse the repository at this point in the history
…and non-iframed editors
  • Loading branch information
Mamaduka committed Jul 13, 2023
1 parent 181b49c commit 0bc378a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/block-editor/src/hooks/margin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export function MarginVisualizer( { clientId, attributes, forceShow } ) {
const margin = attributes?.style?.spacing?.margin;

useEffect( () => {
if ( ! blockElement ) {
if (
! blockElement ||
null === blockElement.ownerDocument.defaultView
) {
return;
}

Expand Down
5 changes: 4 additions & 1 deletion packages/block-editor/src/hooks/padding.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export function PaddingVisualizer( { clientId, attributes, forceShow } ) {
const padding = attributes?.style?.spacing?.padding;

useEffect( () => {
if ( ! blockElement ) {
if (
! blockElement ||
null === blockElement.ownerDocument.defaultView
) {
return;
}

Expand Down

0 comments on commit 0bc378a

Please sign in to comment.