mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-11 06:30:03 +00:00
refactor(studio): single-source timeline selection id-resolution
The DOM-selection to timeline sync routes through the canonical resolveTimelineIdForSelection (source-file, ancestor, active-comp fallback) instead of a narrow domId/id match that mismatched sub-composition clips. The preview-sync equality check compares selection as sets both ways and includes the anchor, so duplicate resolutions no longer mask an unsynced member.
This commit is contained in:
@@ -11,6 +11,7 @@ import { useCallback, useEffect, useRef } from "react";
|
||||
import type { DomEditSelection } from "../components/editor/domEditingTypes";
|
||||
import { STUDIO_GSAP_PANEL_ENABLED } from "../components/editor/manualEditingAvailability";
|
||||
import { usePlayerStore } from "../player";
|
||||
import { resolveTimelineIdForSelection } from "../utils/studioHelpers";
|
||||
import { useDomEditPreviewSync } from "./useDomEditPreviewSync";
|
||||
import { useGsapAnimationsForElement, usePopulateKeyframeCacheForFile } from "./useGsapTweenCache";
|
||||
import { useGsapAnimationFetchFallback } from "./useGsapAnimationFetchFallback";
|
||||
@@ -171,12 +172,12 @@ export function useDomEditWiring({
|
||||
useEffect(() => {
|
||||
if (!domEditSelection?.id) return;
|
||||
const { selectedElementId, elements, setSelectedElementId } = usePlayerStore.getState();
|
||||
const matchKey = elements.find(
|
||||
(el) => el.domId === domEditSelection.id || el.id === domEditSelection.id,
|
||||
);
|
||||
const key = matchKey ? (matchKey.key ?? matchKey.id) : null;
|
||||
// Resolve through the canonical resolver (source-file + ancestor + active-comp
|
||||
// fallback) rather than a narrow domId/id match, so a sub-composition selection
|
||||
// maps to the same clip the rest of the selection pipeline picks.
|
||||
const key = resolveTimelineIdForSelection(domEditSelection, elements, activeCompPath);
|
||||
if (key && key !== selectedElementId) setSelectedElementId(key);
|
||||
}, [domEditSelection?.id]);
|
||||
}, [domEditSelection, activeCompPath]);
|
||||
|
||||
// ── GSAP cache sync ──
|
||||
|
||||
|
||||
Reference in New Issue
Block a user