mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-16 22:58:02 +00:00
chore(studio): name the path that clears a selection after a group move
The drag trace showed the group landing exactly where it was dropped and staying there — no snap-back at any settle sample, and the pointer and the applied delta never more than 2px apart — but two milliseconds after the drop the selection was cleared with seven members still in it. The clear comes from the timeline sync deciding the timeline holds nothing, and that branch said nothing. It says so now, along with whether it is about to act on it. The mirror alongside it reports how many members it managed to publish and whether the anchor was among them, because a member with no timeline row of its own resolves to null and is dropped silently — publish none and the sync reads it back as an empty selection.
This commit is contained in:
@@ -180,12 +180,19 @@ export function useDomSelection({
|
||||
// older contract on purpose: anchoring with preserveSet holds a live set the
|
||||
// element already belongs to (a late async primary must not collapse a group)
|
||||
// and collapses otherwise, which is what a fresh click means.
|
||||
if (group.length > 1) {
|
||||
setTimelineSelectionSet(
|
||||
new Set(group.map(timelineIdFor).filter((id): id is string => Boolean(id))),
|
||||
);
|
||||
}
|
||||
setSelectedTimelineElementId(timelineIdFor(primary), { preserveSet: true });
|
||||
const members = group.map(timelineIdFor).filter((id): id is string => Boolean(id));
|
||||
const anchor = timelineIdFor(primary);
|
||||
// A member with no timeline row of its own resolves to null and is dropped
|
||||
// here, so a group can announce fewer ids than it has — or none, which reads
|
||||
// back as an empty selection and takes the canvas selection with it.
|
||||
logSelect("announce", {
|
||||
group: group.length,
|
||||
published: members.length,
|
||||
anchor,
|
||||
anchorPublished: anchor != null && members.includes(anchor),
|
||||
});
|
||||
if (group.length > 1) setTimelineSelectionSet(new Set(members));
|
||||
setSelectedTimelineElementId(anchor, { preserveSet: true });
|
||||
},
|
||||
[setSelectedTimelineElementId, setTimelineSelectionSet, timelineElements],
|
||||
);
|
||||
@@ -536,6 +543,7 @@ export function useDomSelection({
|
||||
const applyMarqueeSelection = useCallback(
|
||||
// fallow-ignore-next-line complexity
|
||||
(selections: DomEditSelection[], additive: boolean) => {
|
||||
logSelect("marquee", { hits: selections.length, additive });
|
||||
if (selections.length === 0) {
|
||||
if (!additive) applyDomSelection(null, { revealPanel: false });
|
||||
return;
|
||||
|
||||
@@ -94,6 +94,13 @@ export function useTimelineSelectionPreviewSync({
|
||||
|
||||
if (selectedIds.length === 0) {
|
||||
missingSelectionKeyRef.current = "";
|
||||
// The timeline holds nothing, so the canvas is about to hold nothing either.
|
||||
// This is the path that silently drops a selection the user can still see.
|
||||
logSelect("timeline-empty", {
|
||||
had: currentIds.length,
|
||||
previousKey: previousSelectedKey.length > 0,
|
||||
clearing: previousSelectedKey.length > 0 && currentIds.length > 0,
|
||||
});
|
||||
if (previousSelectedKey.length > 0 && currentIds.length > 0) {
|
||||
applyDomSelection(null, { revealPanel: false });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user