Skip to content

fix(studio): delete only the active element's selected keyframes#1453

Open
calcarazgre646 wants to merge 1 commit into
heygen-com:mainfrom
calcarazgre646:fix/studio-delete-keyframes-respects-active-element
Open

fix(studio): delete only the active element's selected keyframes#1453
calcarazgre646 wants to merge 1 commit into
heygen-com:mainfrom
calcarazgre646:fix/studio-delete-keyframes-respects-active-element

Conversation

@calcarazgre646

Copy link
Copy Markdown
Contributor

What

Pressing Delete with keyframes multi-selected could remove keyframes from the wrong element.

Why

selectedKeyframes holds "<elementId>:<percentage>" keys, and that selection can outlive the element it was built on:

  • clicking a clip, clicking a keyframe, selecting a layer, or opening a keyframe context menu changes the active element without clearing the selection, and
  • a shift-selection can span more than one element.

deleteSelectedKeyframes parsed only the percentage from each key (k.split(":")[1]) and applied it to the currently active animation, ignoring which element each selected keyframe actually belonged to. So a stale cross-element selection deleted keyframes the user never targeted on the active element.

Fix

Extract selectedKeyframePercentagesForElement(selectedKeyframes, activeElementId), which keeps only the percentages whose key matches the active element id (splitting on the final : so element ids containing : still match), and route the delete through it.

The common case (all selected keyframes on the active element) is unchanged; stale cross-element keys are skipped instead of being mis-applied to the active element.

Testing

  • New unit tests for selectedKeyframePercentagesForElement (active-element filtering, cross-element drop, empty / no-active-element, colon-in-id, non-finite guard). They fail against the old percentage-only logic.
  • bun run --cwd packages/studio test green, typecheck green, build green.

Pressing Delete with keyframes multi-selected removed keyframes from the
wrong element. selectedKeyframes holds "<elementId>:<percentage>" keys and
can outlive the element it was built on (a clip click, keyframe click, layers
selection, or keyframe context menu changes the active element without clearing
it, and a shift-selection can span elements). deleteSelectedKeyframes parsed
only the percentage from each key and applied it to the active animation,
ignoring which element each selected keyframe belonged to, so a stale selection
deleted keyframes the user never targeted on the active element.

Extract selectedKeyframePercentagesForElement, which keeps only the percentages
whose key matches the active element id, and route the delete through it. The
common case (all selected keyframes on the active element) is unchanged; stale
cross-element keys are skipped instead of mis-applied.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant