diff --git a/packages/studio/src/components/editor/DomEditOverlay.tsx b/packages/studio/src/components/editor/DomEditOverlay.tsx
index a54a892db2..913e6ca342 100644
--- a/packages/studio/src/components/editor/DomEditOverlay.tsx
+++ b/packages/studio/src/components/editor/DomEditOverlay.tsx
@@ -556,6 +556,7 @@ export const DomEditOverlay = memo(function DomEditOverlay({
groupSelections={groupSelections}
activeCompositionPathRef={activeCompositionPathRef}
onSelectionChangeRef={onSelectionChangeRef}
+ iframeRef={iframeRef}
/>
{contextMenu && (
diff --git a/packages/studio/src/components/editor/OffCanvasIndicators.test.tsx b/packages/studio/src/components/editor/OffCanvasIndicators.test.tsx
index 159528aff4..7a05902dc0 100644
--- a/packages/studio/src/components/editor/OffCanvasIndicators.test.tsx
+++ b/packages/studio/src/components/editor/OffCanvasIndicators.test.tsx
@@ -21,6 +21,7 @@ it("rotates an off-canvas indicator with its element", () => {
groupSelections={[]}
activeCompositionPathRef={{ current: null }}
onSelectionChangeRef={{ current: () => undefined }}
+ iframeRef={{ current: null }}
/>,
);
});
diff --git a/packages/studio/src/components/editor/OffCanvasIndicators.tsx b/packages/studio/src/components/editor/OffCanvasIndicators.tsx
index a24be76372..689683c49a 100644
--- a/packages/studio/src/components/editor/OffCanvasIndicators.tsx
+++ b/packages/studio/src/components/editor/OffCanvasIndicators.tsx
@@ -20,6 +20,7 @@ interface OffCanvasIndicatorsProps {
onSelectionChangeRef: React.MutableRefObject<
(selection: DomEditSelection, options?: { revealPanel?: boolean; additive?: boolean }) => void
>;
+ iframeRef: React.RefObject;
}
function clipOutsideCanvas(
@@ -75,6 +76,7 @@ export function OffCanvasIndicators({
groupSelections,
activeCompositionPathRef,
onSelectionChangeRef,
+ iframeRef,
}: OffCanvasIndicatorsProps): React.ReactElement {
return (
<>
@@ -100,13 +102,14 @@ export function OffCanvasIndicators({
const selectOffCanvas = async () => {
const el = elements.current.get(r.key);
if (!el) return;
- const { resolveDomEditSelection } = await import("./domEditingLayers");
const acp = activeCompositionPathRef.current ?? "index.html";
- const sel = await resolveDomEditSelection(el, {
+ const options = {
activeCompositionPath: acp,
isMasterView: !acp || acp === "index.html",
skipSourceProbe: true,
- });
+ };
+ const { resolveIndicatorSelection } = await import("./previewOffCanvas");
+ const sel = await resolveIndicatorSelection(iframeRef.current, el, options);
if (sel) onSelectionChangeRef.current(sel, { revealPanel: true });
};
const handleClick = (e: React.MouseEvent) => {
diff --git a/packages/studio/src/components/editor/offCanvasIndicatorGeometry.ts b/packages/studio/src/components/editor/offCanvasIndicatorGeometry.ts
index 806342f3a8..105db2ea20 100644
--- a/packages/studio/src/components/editor/offCanvasIndicatorGeometry.ts
+++ b/packages/studio/src/components/editor/offCanvasIndicatorGeometry.ts
@@ -21,7 +21,7 @@ function offCanvasSignature(rects: OffCanvasRect[]): string {
.join("|");
}
-function extendsOutside(
+export function extendsOutside(
rect: Omit,
comp: { left: number; top: number; width: number; height: number },
): boolean {
@@ -126,9 +126,20 @@ export function recomputeOffCanvasIndicators(
}
}
+ publishOffCanvasRects(rects, elMap, sigRef, elementsRef, setRects);
+}
+
+/** Shows `rects` unless they are what is already shown. */
+export function publishOffCanvasRects(
+ rects: OffCanvasRect[],
+ elements: Map,
+ sigRef: React.MutableRefObject,
+ elementsRef: React.MutableRefObject