Skip to content

Commit d48440a

Browse files
committed
fix(studio): keep the host row when drilling into a sub-composition
The sub-composition drill-in replaced the host row with its children. Since expansion is also driven by the playhead alone (paused auto-expand), an ordinary seek into a sub-composition made the host row disappear, taking its keyframe lane with it: diamonds render per row from keyframeCache.get( elementKey), so no row means no diamonds. Reproduced live with no drag at all, seek 0 gave 3 diamonds, seek 7.68 gave 0, seek 0.2 gave 3. Make the expansion additive instead. The host row stays and its children are appended directly below it. The synthetic fractional lanes already used for children sit strictly between the host's lane and the next integer, so the host keeps its own row without colliding with anything. The time-keyed auto-expand itself is unchanged.
1 parent 1254698 commit d48440a

2 files changed

Lines changed: 75 additions & 3 deletions

File tree

‎packages/studio/src/player/hooks/useExpandedTimelineElements.test.ts‎

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,73 @@ describe("buildExpandedElements", () => {
240240
expect(pills[0]!.duration).toBe(6);
241241
expect(pills[0]!.sourceFile).toBe("scene.html");
242242
expect(pills.map((pill) => pill.stackingContextId)).toEqual(["css:0.0", "css:0.1", "css:0.1"]);
243-
// The host row is replaced by its children.
244-
expect(out.some((e) => e.domId === "scene-host")).toBe(false);
243+
// The host row survives the expansion; its children are added under it.
244+
expect(out.some((e) => e.id === "scene-host")).toBe(true);
245+
});
246+
247+
// fallow-ignore-next-line code-duplication
248+
it("keeps the host row and appends its children directly below it", () => {
249+
const elements = [
250+
el({
251+
id: "s3",
252+
domId: "s3",
253+
key: "index.html#s3",
254+
start: 16,
255+
duration: 7,
256+
compositionSrc: "stats.html",
257+
}),
258+
el({ id: "outro", start: 23, duration: 3, track: 1 }),
259+
];
260+
const manifest = [
261+
clip({ id: "s3", start: 16, duration: 7, compositionSrc: "stats.html" }),
262+
clip({ id: "stat-1", start: 16.5, duration: 5 }),
263+
clip({ id: "stat-2", start: 16.9, duration: 5 }),
264+
];
265+
const parentMap = new Map([
266+
["stat-1", "s3"],
267+
["stat-2", "s3"],
268+
]);
269+
270+
const out = buildExpandedElements(elements, manifest, parentMap, "s3", "s3");
271+
272+
const hostIndex = out.findIndex((e) => e.id === "s3");
273+
expect(hostIndex).toBeGreaterThanOrEqual(0);
274+
// Host row untouched (same key → same keyframe lane), children nested under it.
275+
expect(out[hostIndex]!.key).toBe("index.html#s3");
276+
expect(out[hostIndex]!.track).toBe(0);
277+
expect(out[hostIndex + 1]!.domId).toBe("stat-1");
278+
expect(out[hostIndex + 2]!.domId).toBe("stat-2");
279+
// Exactly one more row than the old substitution behaviour (host + 2 children + outro).
280+
expect(out).toHaveLength(4);
281+
});
282+
283+
it("keeps the host row present at every playhead position (keyframe lane repro)", () => {
284+
// Live repro with no drag at all: seek 0 gave 3 diamonds, seek 7.68 gave 0,
285+
// seek 0.2 gave 3. Diamonds render per row from keyframeCache.get(elementKey),
286+
// so the whole lane went with the host row whenever the paused drill-in
287+
// substituted it for its children.
288+
const elements = [
289+
el({ id: "scene", domId: "scene", key: "index.html#scene", start: 0, duration: 12 }),
290+
];
291+
const manifest = [
292+
clip({ id: "scene", start: 0, duration: 12, compositionSrc: "scene.html" }),
293+
clip({ id: "headline", start: 0, duration: 12 }),
294+
];
295+
const parentMap = new Map([["headline", "scene"]]);
296+
297+
for (const currentTime of [0, 7.68, 0.2]) {
298+
const rawId = resolveTimelineExpansionRawId({
299+
selectedElementId: null,
300+
isPlaying: false,
301+
currentTime,
302+
manifest,
303+
parentMap,
304+
});
305+
const rows = rawId
306+
? buildExpandedElements(elements, manifest, parentMap, rawId, rawId)
307+
: elements;
308+
expect(rows.map((row) => row.key)).toContain("index.html#scene");
309+
}
245310
});
246311

247312
// Regression: DOM-only children were synthesized against the TOP-LEVEL element

‎packages/studio/src/player/hooks/useExpandedTimelineElements.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,16 @@ export function buildExpandedElements(
284284
);
285285
if (expanded.length === 0) return filterToTopLevel(elements, parentMap);
286286

287+
// ADDITIVE drill-in: the host row stays and its children are appended under
288+
// it. Expansion is also triggered by the playhead alone (paused auto-expand),
289+
// so substituting the host row made it vanish on an ordinary seek — and with
290+
// it the host's keyframe lane, since diamonds render per row from
291+
// `keyframeCache.get(elementKey)`. The synthetic fractional lanes above sit
292+
// strictly between the host's lane and the next integer, so the children have
293+
// their own rows without the host having to give up its own.
287294
return elements
288295
.filter((el) => (el.key ?? el.id) === parentKey || !parentMap.has(el.domId ?? el.id))
289-
.flatMap((el) => ((el.key ?? el.id) === parentKey ? expanded : [el]));
296+
.flatMap((el) => ((el.key ?? el.id) === parentKey ? [el, ...expanded] : [el]));
290297
}
291298

292299
export function useExpandedTimelineElements(): TimelineElement[] {

0 commit comments

Comments
 (0)