mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-07 01:56:04 +00:00
fix(studio): atomic timing pin, expanded-list Hide All, repeated-host matching, pointercancel revert
Fixes real bugs from two independent re-reviews (#2225 @ 65954c3804, #2416 @ beaf4ffbf6): - FlatTimingRow's pinRange committed a pinned start+duration range through TWO sequential onSetAttribute calls. Each resolves domEditSelection fresh from current hook state, so a selection change between the two awaits could misdirect the second write at the newly-selected element instead of the one being edited, and a failure of just the second call left the pair half-applied (inconsistent inferred/explicit state). Added commitDataAttributes/handleDomAttributesCommit (mirroring onCommitAnimatedProperties's same-shaped fix for GSAP property batches): one PatchOperation[] persist call against an explicit, caller-supplied selection — not the "current" one — threaded through as the new optional onSetAttributes prop. pinRange uses it when provided, falls back to the old sequential behavior otherwise. - Hide All silently dropped nested sub-composition children: a selection inside a sub-comp with no timeline-store entry of its own resolves to a virtual `sourceFile#domId` key (the fallback branch exists so the expansion hook can later resolve it via clipParentMap), but toggleTimelineElementHidden only searched the RAW store list, which never contains that key. useTimelineElementVisibilityEditing now resolves against useExpandedTimelineElements() instead, matching the track-based toggle's existing approach — the expanded list synthesizes a real, patchable TimelineElement (matching key/domId/sourceFile) for each visible child whenever its host is currently expanded. - Two composition hosts importing the same sub-composition collapsed to the first one: findMatchingTimelineElementId ORed domId/selector/ compositionSrc matches with equal priority in a single per-element scan, so `.find()` could stop at an EARLIER, unrelated host that merely shared the compositionSrc, before the scan ever reached the correct domId/ selector match further down the list. Restructured to try domId, then selector, across the WHOLE list first; compositionSrc-only matching is now a true last resort for when neither identifies a specific element. - FlatSlider's native pointercancel handler (a platform-level gesture abort — scroll/touch takeover, pen leaving range) manually duplicated the pointer-capture release logic instead of calling cancelDrag, so it never reverted to the pre-drag value — leaving whatever intermediate position the pointer last reached committed, unlike the Escape/right-click paths added in the previous round. Now calls cancelDrag directly. - useColorGradingController's flushPendingPersist read identityKeyRef.current fresh at flush time rather than a value snapshotted when the edit was scheduled. Defensive fix: added pendingPersistIdentityRef, set alongside pendingPersistValueRef in commitColorGrading, read by flushPendingPersist instead of the live ref — closes the gap regardless of how unlikely the actual race is given the identity-cleanup effect's existing eager-flush behavior. Two prior findings re-verified as already fixed further up this same Graphite stack (not re-fixed here, per established stack-order handling): metadata-cache negative-caching (267cdfce1) and cross-file selectionIdentityKey (6f40e03a1), both landing after #2225's reviewed head. StudioRightPanel.tsx crossed the 600-line file-size gate after wiring the new onSetAttributes prop through; extracted the inspector split-pane resize handlers (previously inlined) into their own useInspectorSplitResize hook. New regression tests: repeated-composition-host resolution, atomic vs. fallback pinRange commit paths, pointercancel revert. Full studio suite still at the known pre-existing 55-failure baseline, zero new regressions. Typecheck/oxlint/oxfmt clean.
This commit is contained in:
@@ -48,6 +48,51 @@ describe("findMatchingTimelineElementId", () => {
|
||||
it("returns null for an unmatched element in index.html", () => {
|
||||
expect(findMatchingTimelineElementId({ id: "ghost", sourceFile: "index.html" }, [])).toBe(null);
|
||||
});
|
||||
|
||||
it("resolves the correct repeated composition host by domId, not the first host sharing the same compositionSrc", () => {
|
||||
// Two hosts import the SAME sub-composition — only compositionSrc alone
|
||||
// can't tell them apart, but each still has its own domId (as any
|
||||
// element does). Selecting the SECOND host must not collapse to the
|
||||
// first one just because an earlier, unrelated element also happens to
|
||||
// share its compositionSrc.
|
||||
const els = [
|
||||
el({ id: "host-a", domId: "host-a", sourceFile: "index.html", compositionSrc: "scene.html" }),
|
||||
el({ id: "host-b", domId: "host-b", sourceFile: "index.html", compositionSrc: "scene.html" }),
|
||||
];
|
||||
expect(
|
||||
findMatchingTimelineElementId(
|
||||
{
|
||||
id: "host-b",
|
||||
sourceFile: "index.html",
|
||||
compositionSrc: "scene.html",
|
||||
isCompositionHost: true,
|
||||
},
|
||||
els,
|
||||
),
|
||||
).toBe("host-b");
|
||||
});
|
||||
|
||||
it("falls back to compositionSrc-only matching when the host selection has neither a domId nor a selector", () => {
|
||||
const els = [
|
||||
el({
|
||||
id: "host-only",
|
||||
domId: undefined,
|
||||
sourceFile: "index.html",
|
||||
compositionSrc: "scene.html",
|
||||
}),
|
||||
];
|
||||
expect(
|
||||
findMatchingTimelineElementId(
|
||||
{
|
||||
id: undefined,
|
||||
sourceFile: "index.html",
|
||||
compositionSrc: "scene.html",
|
||||
isCompositionHost: true,
|
||||
},
|
||||
els,
|
||||
),
|
||||
).toBe("host-only");
|
||||
});
|
||||
});
|
||||
|
||||
describe("findTimelineIdByAncestor", () => {
|
||||
|
||||
@@ -161,25 +161,34 @@ function matchesBySelector(selection: ElementMatchSelection, element: TimelineEl
|
||||
);
|
||||
}
|
||||
|
||||
function elementMatchesSelection(
|
||||
selection: ElementMatchSelection,
|
||||
element: TimelineElement,
|
||||
selectionSourceFile: string,
|
||||
): boolean {
|
||||
return (
|
||||
matchesByDomId(selection, element, selectionSourceFile) ||
|
||||
matchesByCompositionHost(selection, element) ||
|
||||
matchesBySelector(selection, element)
|
||||
);
|
||||
}
|
||||
|
||||
export function findMatchingTimelineElementId(
|
||||
selection: ElementMatchSelection,
|
||||
elements: TimelineElement[],
|
||||
): string | null {
|
||||
const selectionSourceFile = selection.sourceFile || "index.html";
|
||||
const match = elements.find((el) => elementMatchesSelection(selection, el, selectionSourceFile));
|
||||
if (match) return match.key ?? match.id;
|
||||
// Priority matters, not just "any of the three": a composition-host
|
||||
// selection always carries its OWN id/selector too (computed generically
|
||||
// for any element), so two repeated hosts sharing the same compositionSrc
|
||||
// are still individually addressable by id/selector. Checking
|
||||
// matchesByCompositionHost with equal priority in a single OR-per-element
|
||||
// scan let `.find()` stop at an EARLIER, unrelated host that merely shares
|
||||
// the compositionSrc, before the scan ever reached the correct id/selector
|
||||
// match further down the list — collapsing every repeated host to the
|
||||
// first one. Try id, then selector, across the WHOLE list first; only fall
|
||||
// back to the coarser compositionSrc-only match when neither identifies a
|
||||
// specific element.
|
||||
const byId = selection.id
|
||||
? elements.find((el) => matchesByDomId(selection, el, selectionSourceFile))
|
||||
: undefined;
|
||||
if (byId) return byId.key ?? byId.id;
|
||||
|
||||
const bySelector = selection.selector
|
||||
? elements.find((el) => matchesBySelector(selection, el))
|
||||
: undefined;
|
||||
if (bySelector) return bySelector.key ?? bySelector.id;
|
||||
|
||||
const byHost = elements.find((el) => matchesByCompositionHost(selection, el));
|
||||
if (byHost) return byHost.key ?? byHost.id;
|
||||
|
||||
// Child inside a sub-composition: return a qualified ID so the expansion
|
||||
// hook can resolve the child via clipParentMap even though no timeline
|
||||
|
||||
Reference in New Issue
Block a user