Skip to content

Commit

Permalink
introduce the concept of canvas via a 1st variable
Browse files Browse the repository at this point in the history
  • Loading branch information
draganescu committed Oct 14, 2024
1 parent 9fadd33 commit 0afb084
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/block-editor/src/components/block-popover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ function BlockPopover(

return {
getBoundingClientRect() {
// The popover should be positioned relative to the root element of the canvas.
// The popover should be positioned relative to the root element of the canvas. The canvas is the container of
// content in zoom out mode.
// FIXME: This should not be accessed by classname.
const rootSectionElement = selectedElement.closest(
const canvasElement = selectedElement.closest(
'.block-editor-iframe__body'
);
// The zoom out view has a vertical block toolbar that should always
Expand All @@ -131,8 +132,8 @@ function BlockPopover(
// Compute the height based on the parent section of the
// selected block, because the selected block may be
// shorter than the section.
const rootSectionElementRect =
getVisibleElementBounds( rootSectionElement );
const canvasElementRect =
getVisibleElementBounds( canvasElement );
const parentSectionElementRect =
getVisibleElementBounds( parentSectionElement );
const anchorHeight =
Expand All @@ -141,9 +142,9 @@ function BlockPopover(

// Always use the width of the section root element to make sure
// the toolbar is always on the edge of the canvas.
const anchorWidth = rootSectionElementRect.width;
const anchorWidth = canvasElementRect.width;
return new window.DOMRectReadOnly(
rootSectionElementRect.left,
canvasElementRect.left,
parentSectionElementRect.top,
anchorWidth,
anchorHeight
Expand Down

0 comments on commit 0afb084

Please sign in to comment.