Refresh animation keyframe errors after deleting a category (#3392)#3398
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two commits, both needed:
Subscribe to
CategoryDelete— the State Animation plugin recomputes keyframe errors onStateAdd/StateDelete/StateRename/.../AfterUndobut not category delete, so a keyframe referencing a state in a deleted category kept its normal icon until the element was reselected.CategoryDeletealready exists (PluginBase.CategoryDelete, raised fromDeleteLogic); route it toRefreshViewModel, matchingHandleStateDelete.Preserve the broken keyframe's
StateName— fix Align to pixels while dragging #1 exposed a coercion bug.RefreshViewModel→RefreshAvailableStatesdoesAvailableStates.ReplaceWith(...), which dropped the now-deleted state from the editable state ComboBox'sItemsSource. The editable ComboBox then coerced itsText(bound TwoWay toStateName) to empty, clearingStateNameand 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
GetAvailableStatesthat 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 viaRefreshErrors/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. TheCategoryDeletesubscription is event wiring onto the already-testedRefreshErrorspath (no unit seam for the plugin event), matching the precedent of theAfterUndofix in #3389.Closes #3392
🤖 Generated with Claude Code