Skip to content

Commit

Permalink
adds new mutation observers on the html element that is scaled by the…
Browse files Browse the repository at this point in the history
… iframe, which is the element that will have its attributes change if the workspave is shrunk
  • Loading branch information
draganescu committed Oct 9, 2024
1 parent 6be7f8f commit 68650fb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/block-editor/src/components/block-popover/inbetween.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,16 @@ function BlockPopoverInbetween( {
const observer = new window.MutationObserver( forcePopoverRecompute );
observer.observe( previousElement, { attributes: true } );

const zoomedOutObserver = new window.MutationObserver(
forcePopoverRecompute
);
zoomedOutObserver.observe( previousElement.closest( 'html' ), {
attributes: true,
} );

return () => {
observer.disconnect();
zoomedOutObserver.disconnect();
};
}, [ previousElement ] );

Expand All @@ -192,8 +200,16 @@ function BlockPopoverInbetween( {
const observer = new window.MutationObserver( forcePopoverRecompute );
observer.observe( nextElement, { attributes: true } );

const zoomedOutObserver = new window.MutationObserver(
forcePopoverRecompute
);
zoomedOutObserver.observe( nextElement.closest( 'html' ), {
attributes: true,
} );

return () => {
observer.disconnect();
zoomedOutObserver.disconnect();
};
}, [ nextElement ] );

Expand Down
8 changes: 8 additions & 0 deletions packages/block-editor/src/components/block-popover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,16 @@ function BlockPopover(
);
observer.observe( selectedElement, { attributes: true } );

const zoomedOutObserver = new window.MutationObserver(
forceRecomputePopoverDimensions
);
zoomedOutObserver.observe( selectedElement.closest( 'html' ), {
attributes: true,
} );

return () => {
observer.disconnect();
zoomedOutObserver.disconnect();
};
}, [ selectedElement ] );

Expand Down

0 comments on commit 68650fb

Please sign in to comment.