Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: not hiding elements that share borders [TOL-2545] #965

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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