Skip to content

Refresh animation keyframe errors after deleting a category (#3392)#3398

Merged
vchelaru merged 2 commits into
mainfrom
3392-anim-cat-delete
Jun 28, 2026
Merged

Refresh animation keyframe errors after deleting a category (#3392)#3398
vchelaru merged 2 commits into
mainfrom
3392-anim-cat-delete

Conversation

@vchelaru

@vchelaru vchelaru commented Jun 28, 2026

Copy link
Copy Markdown
Owner

What

Two commits, both needed:

  1. Subscribe to CategoryDelete — the State Animation plugin recomputes keyframe errors on StateAdd/StateDelete/StateRename/.../AfterUndo but not category delete, so a keyframe referencing a state in a deleted category kept its normal icon until the element was reselected. CategoryDelete already exists (PluginBase.CategoryDelete, raised from DeleteLogic); route it to RefreshViewModel, matching HandleStateDelete.

  2. Preserve the broken keyframe's StateNamefix Align to pixels while dragging #1 exposed a coercion bug. RefreshViewModelRefreshAvailableStates does AvailableStates.ReplaceWith(...), which dropped the now-deleted state from the editable state ComboBox's ItemsSource. The editable ComboBox then coerced its Text (bound TwoWay to StateName) to empty, clearing StateName and collapsing the broken state keyframe into an event (flag icon) instead of the red broken-reference icon.

    Fix: extract the list-building into a testable static GetAvailableStates that keeps any state still referenced by a keyframe even when it no longer exists on the element, so the ComboBox holds its selection. Brokenness is still reported via RefreshErrors/HasValidState (computed against the element), so the red icon and "Could not find state" label still show.

Tests

GetAvailableStates_PreservesKeyframeStateName_WhenItsCategoryWasDeleted (red → green) pins the VM-level contract: after a category delete the referenced state stays in the available-states list so the ComboBox can't drop it. The WPF coercion itself (Text → StateName) is verified manually. The CategoryDelete subscription is event wiring onto the already-tested RefreshErrors path (no unit seam for the plugin event), matching the precedent of the AfterUndo fix in #3389.

Closes #3392

🤖 Generated with Claude Code

Deleting a whole category (and its states) doesn't fire the granular StateDelete plugin event the State Animation plugin listens to, so a keyframe that referenced a state in the deleted category kept its non-error icon until the element was reselected.

Subscribe to the existing CategoryDelete plugin event and RefreshViewModel, matching HandleStateDelete and the AfterUndo wiring added for the same icon (#3389). Event wiring onto the already-unit-tested RefreshErrors path; no unit seam for the plugin event itself, verified manually.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The CategoryDelete subscription added in the previous commit makes RefreshViewModel run on category delete, which recomputes the available-state list bound to each keyframe's editable state ComboBox. ReplaceWith then dropped the still-referenced (now-deleted) state from the ComboBox's ItemsSource, and the editable ComboBox coerced its Text - bound TwoWay to StateName - to empty. That cleared StateName, collapsing the broken state keyframe into an event (flag icon) instead of showing the red broken-reference icon.

Extract RefreshAvailableStates' list building into a testable static GetAvailableStates that also keeps any state still referenced by a keyframe even when it no longer exists on the element, so the ComboBox holds its selection. Brokenness is still reported via RefreshErrors/HasValidState, computed against the element, so the red icon and 'Could not find state' label still show.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vchelaru vchelaru merged commit fa2bfc3 into main Jun 28, 2026
3 checks passed
@vchelaru vchelaru deleted the 3392-anim-cat-delete branch June 28, 2026 11:51
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.

Broken-keyframe error icon doesn't refresh on category delete until reselect Align to pixels while dragging

1 participant