Skip to content

Write HTML. Render video. Built for agents.

fix(studio): realm-safe isHTMLElement so timeline z-index commits land

Miguel Angel Simon Sierraeef500c8902d
diff --git a/packages/studio/src/hooks/timelineEditingHelpers.ts b/packages/studio/src/hooks/timelineEditingHelpers.ts
index 6e14c32b50..6a403a6b98 100644
--- a/packages/studio/src/hooks/timelineEditingHelpers.ts
+++ b/packages/studio/src/hooks/timelineEditingHelpers.ts
@@ -12,7 +12,12 @@ import type { EditHistoryKind } from "../utils/editHistory";
import type { TimelineZIndexReorderCommit } from "./useTimelineEditingTypes";
function isHTMLElement(element: Element | null): element is HTMLElement {
- return element != null && element instanceof HTMLElement;
+ if (!element) return false;
+ // Use the element's OWN realm's HTMLElement: timeline clips live in the preview
+ // iframe, and cross-realm `element instanceof HTMLElement` (main window) is
+ // always false — which silently dropped every timeline z-index commit.
+ const Ctor = element.ownerDocument?.defaultView?.HTMLElement ?? globalThis.HTMLElement;
+ return element instanceof Ctor;
}
/**