Skip to content

Commit

Permalink
fix: not hiding elements that share borders [TOL-2545] (#965)
Browse files Browse the repository at this point in the history
  • Loading branch information
aodhagan-cf authored Nov 28, 2024
1 parent ed960a3 commit 876d539
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/live-preview-sdk/src/inspectorMode/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,16 @@ export function getAllTaggedEntries({

const isElementOverlapped = (element: Element, coordinates: DOMRect, root = window.document) => {
const { top, right, bottom, left } = coordinates;
const topLeft = root.elementFromPoint(left, top);
const topRight = root.elementFromPoint(right, top);
const bottomLeft = root.elementFromPoint(left, bottom);
const bottomRight = root.elementFromPoint(right, bottom);

return (
topLeft === element || topRight === element || bottomLeft === element || bottomRight === element
const topLeft = root.elementFromPoint(left + 1, top + 1);
const topRight = root.elementFromPoint(right - 1, top + 1);
const bottomLeft = root.elementFromPoint(left + 1, bottom - 1);
const bottomRight = root.elementFromPoint(right - 1, bottom - 1);

return !(
topLeft === element &&
topRight === element &&
bottomLeft === element &&
bottomRight === element
);
};

Expand All @@ -380,7 +383,7 @@ const addVisibilityToTaggedElements = (
checkOpacity: true,
checkVisibilityCSS: true,
}),
isCoveredByOtherElement: !isElementOverlapped(
isCoveredByOtherElement: isElementOverlapped(
taggedElement.element!,
taggedElement.coordinates!,
root,
Expand Down

0 comments on commit 876d539

Please sign in to comment.