Skip to content

Write HTML. Render video. Built for agents.

Merge pull request #2111 from heygen-com/feat/timeline-multiselect

Miguel Ángeldff27cb1dfd1
diff --cc packages/studio/src/hooks/useDomSelection.ts
index 8a6efa5ce0,f124d37535..3fd25c9158
--- a/packages/studio/src/hooks/useDomSelection.ts
+++ b/packages/studio/src/hooks/useDomSelection.ts
@@@ -207,20 -204,26 +206,30 @@@ export function useDomSelection(
if (nextSelection) {
if (options?.revealPanel !== false) {
setRightCollapsed(false);
- setRightPanelTab("design");
+ // Keep the Variables tab in place — selecting elements is part of
+ // the bind flow there; yanking to Design would lose the context.
+ if (rightPanelTabRef.current !== "variables") {
+ setRightPanelTab("design");
+ }
}
- const nextSelectedTimelineId =
- findMatchingTimelineElementId(nextSelection, timelineElements) ??
- findTimelineIdByAncestor(
- nextSelection.element,
- timelineElements,
- nextSelection.sourceFile || "index.html",
- );
- setSelectedTimelineElementId(nextSelectedTimelineId);
+ // Mirror the whole DOM group to the store so it stays the single source of
+ // truth: a single selection collapses to one id; a preserved group (echo
+ // during a gesture) keeps every member instead of shrinking to the anchor.
+ const anchorId = resolveTimelineIdForSelection(
+ nextSelection,
+ timelineElements,
+ activeCompPath,
+ );
+ const groupIds = nextGroup
+ .map((selection) =>
+ resolveTimelineIdForSelection(selection, timelineElements, activeCompPath),
+ )
+ .filter((id): id is string => Boolean(id));
+ if (groupIds.length > 0) {
+ usePlayerStore.getState().setSelection(groupIds, anchorId);
+ } else {
+ setSelectedTimelineElementId(anchorId);
+ }
return;
}