Skip to content

Fix .Animate() configuration comparison and removal ordering - #1499

Merged
Alexandre Zollinger Chohfi (azchohfi) merged 4 commits into
microsoft:mainfrom
PaperHammer:fix/animate-property-updates
Nov 16, 2026
Merged

Alexandre Zollinger Chohfi (azchohfi) merged 4 commits into
microsoft:mainfrom
PaperHammer:fix/animate-property-updates

Conversation

@PaperHammer

@PaperHammer PaperHammer (PaperHammer) commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Changes to .Animate() alone can be skipped because shallow comparison does not check AnimationConfig. Outgoing implicit channels are also cleared too late when the configuration is removed, allowing setters to trigger the previous animation once more.

This change compares AnimationConfig by value and releases dropped implicit channels before handler dispatch. It handles both complete removal and narrowing the property flags, such as changing Opacity | Scale to Opacity. Equivalent configurations remain eligible for skipping.

Cleanup uses the difference between the old and new flags:

  • Remove only channels no longer declared by .Animate().
  • Preserve layout-owned Offset when both renders retain LayoutAnimation.AnimateOffset.
  • Skip cleanup when no channels were dropped.
  • Keep the existing post-update installation order, so independently declared transitions can be reapplied without a later cleanup deleting them.
  • Clean the original control before dispatch, leaving freshly mounted replacements untouched.

The animation guide is shortened to user-facing behavior, with the flags and compositor-ceiling paragraphs kept together. Relative source links and line-number anchors are removed from both the template and generated guide. The changelog is updated accordingly.

Linked issue / spec

Fixes #1498.

Follow-up to the animation review discussion in #1472.
Related design: spec 014, Feature 3.

This PR covers:

  1. .Animate() configuration changes being skipped.
  2. Outgoing implicit channels being cleared too late during complete removal.
  3. Dropped channels remaining installed when the animation flags are narrowed.

The remaining shallow-comparison gaps for other animation extras will be addressed in a follow-up PR, including consideration of a grouped configuration design and its performance impact.

Handoff-Visual transform-write conflicts after .Animate() or WithAnimation also remain for a separate follow-up. AnimationHelper is unchanged here.

Test plan

  • Added unit coverage for configuration addition/removal, curve changes, property-flag changes, and separately allocated equivalent configurations.
  • Added native coverage for direct Update and parent child-skip paths, including successful skipping of equivalent configurations.
  • Extended ConfigurationAcrossUpdates with a narrowing step after expansion, verifying that Scale is removed while Opacity and its duration remain.
  • Covered complete removal and flag narrowing on ordinary Buttons, including .Set(...) writes without manually stopping the outgoing animation.
  • Checked that the dropped Scale channel is absent before the setter writes, preventing it from triggering the old animation.
  • Verified retained layout Offset inside the setter, before the later layout pass could recreate it, and checked retained Offset/Size afterward.
  • Verified that the independently declared Scale transition retains its own 170 ms duration after the update.
  • Confirmed the narrowing regressions fail before the fix: 11 assertions failed, and all passed after applying the mask-difference change.

Latest validation results:

  • Release unit-project build: passed, 0 warnings and 0 errors.
  • Release native Host build: passed, 0 warnings and 0 errors.
  • Related unit tests: 332 passed, 16 skipped, 0 failed.
  • Native regression fixtures: 75 passed, 0 failed, covering animation configuration/removal/narrowing, Flyout targets, animation scopes, layout animation, pool cleanup, and custom-decorator unmount.
  • Animation documentation regenerated; repeated generation produced no changes.
  • Animation topic validation: passed, 0 errors and 0 warnings.
  • mkdocs build --strict: passed.
  • git diff --check: passed.

Documentation generation also reported unresolved-cref notices on unrelated reference pages; those pages are unchanged.

The full unit suite, full solution build, packaged/AOT tests, and E2E tests were not run.

Risk / breaking changes

  • No public API changes, new state fields, caches, or dependencies.
  • Configuration comparison preserves the existing no-extras fast path.
  • Dropped-channel selection uses a flag mask and avoids cleanup when the mask is zero.
  • Cleanup remains before handlers and setters, with the existing retained-layout-Offset exception.
  • Existing curve-source selection and pool policy are unchanged.
  • Broader layout-animation collection behavior remains outside this PR.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix looks right for the full-removal case and the tests are solid. Two things before merging. The source links in the animation guide will fail the strict mkdocs check, and narrowing the Animate flags still leaves the dropped channels installed. Details inline.

Comment thread src/Reactor/Core/Element.cs Resolved
Comment thread src/Reactor/Core/Reconciler.Update.cs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the animation configuration and removal-ordering fixes.

No open issues 🎉

What changed in this PR

Fixes the two .Animate() update issues tracked in #1498: configuration-only changes being skipped and removed animations retriggering during updates.

Changes:

  • Compare animation configurations by value while preserving skipping for equivalent configurations.
  • Clear outgoing implicit channels before handlers and setters run, preserving retained layout Offset and transitions reapplied during the update.
  • Add unit and native regression coverage, and update animation documentation and the changelog.
File Description
tests/​Reactor.Tests/​ElementTests.cs Tests configuration changes and equivalent-value skipping.
tests/​Reactor.AppTests.Host/​SelfTest/​SelfTestFixtureRegistry.cs Registers the new animation configuration fixtures.
tests/​Reactor.AppTests.Host/​SelfTest/​Fixtures/​AnimationCombinationTests.cs Tests removal ordering and preservation of layout channels and independent transitions.
tests/​Reactor.AppTests.Host/​SelfTest/​Fixtures/​AnimateModifierTests.cs Tests configuration updates through direct and parent child-skip paths.
src/​Reactor/​Core/​Reconciler.Update.cs Moves outgoing animation cleanup before handler dispatch.
src/​Reactor/​Core/​Reconciler.cs Limits cleanup to specified implicit animation channels.
src/​Reactor/​Core/​Element.cs Includes animation configuration in shallow comparison.
docs/​guide/​animation.md Updates the generated animation guide.
docs/​_pipeline/​templates/​animation.md.dt Documents comparison and removal behavior with source links.
CHANGELOG.md Records both animation fixes.

Review effort: Balanced

@PaperHammer

PaperHammer (PaperHammer) commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Thank you for your review and continued guidance. I’ve pushed the documentation cleanup and flag-narrowing fix, with tests covering direct updates, parent child-skip, setter ordering, retained layout Offset, and independent transitions. I’ve also updated the PR description to reflect these changes and the latest test results.

I’d like to address the remaining animation-extras comparisons in a separate follow-up PR, where I can assess the grouped configuration approach and its performance impact.

Could you please take another look when you have time? Thank you!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Removing a Button’s .Animate() can incorrectly clear the retained outer layout’s Offset animation, causing .Set(...) writes to run without the intended animation.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Preserve outer layout animation when an inner decorator removes its animation

src/​Reactor/​Core/​Reconciler.Update.cs:219

For Flyout(Button("Go").Animate(curve, AnimateProperty.Offset), content).LayoutAnimation(layout) with layout Offset enabled, removing the Button's .Animate() clears the retained outer layout's Offset channel because both Button-local LayoutAnimation values are null. An Offset write in the Button's .Set(...) then runs without that animation; the outer update reinstalls it too late. Account for retained layout ownership across decorators sharing the control, and add an inside-setter assertion for this arrangement.

Review effort: Balanced

@azchohfi

Copy link
Copy Markdown
Collaborator

Thanks, the narrowing fix and the new tests look good, and the guide reads much better now. I'll approve once CI is green.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is green, thanks for the quick turnaround.

Resolve the CHANGELOG conflict under Fixed by keeping both the .Animate() entries and main's new entries.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

[Bug] .Animate() configuration changes can be skipped and removed animations can retrigger

3 participants