Skip to content

fix(toggle-animation): remove collapsed content before animation reset - #17965

Open
teodosiah wants to merge 8 commits into
masterfrom
thristodorova/fix-17964
Open

teodosiah wants to merge 8 commits into
masterfrom
thristodorova/fix-17964

Conversation

@teodosiah

@teodosiah teodosiah commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #17964

Description

Motivation / Context

Type of Change (check all that apply):

  • Bug fix
  • New functionality
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (no functional changes)
  • Documentation
  • Demos
  • CI/CD
  • Tests
  • Changelog
  • Skills/Agents

Component(s) / Area(s) Affected:

How Has This Been Tested?

  • Unit tests
  • Manual testing
  • Automated e2e tests

Test Configuration:

  • Angular version:
  • Browser(s):
  • OS:

Screenshots / Recordings

Checklist:

  • All relevant labels have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them
  • Accessibility (ARIA, keyboard navigation, focus management) has been verified

Copilot AI balanced review requested due to automatic review settings November 11, 2026 11:49

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.

🟡 Changes recommended

A regression test is missing for synchronous body removal before animation reset, and existing collapse tests also pass with the old behavior, leaving the flicker unguarded.

1 open issue
What changed in this PR

This PR addresses #17964 by rendering expansion-panel collapse synchronously to prevent flicker in zoneless apps, including accordion and banner components built on the panel.

Changes:

  • Replaces markForCheck() with detectChanges() after collapse.
  • Adds a comment explaining why the body must be removed before the close-animation player resets.
File Description
projects/​igniteui-angular/​expansion-panel/​src/​expansion-panel/​expansion-panel.component.ts Makes collapse rendering synchronous to prevent a full-height flash after animation.

Review effort: Balanced

@teodosiah teodosiah added the ❌ status: awaiting-test PRs awaiting manual verification label Nov 11, 2026
@teodosiah
teodosiah requested a review from mddragnev November 11, 2026 12:31

@mddragnev mddragnev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems to be a more general issue. The tree and the vertical stepper have the same issue. Might be better to fix this in the AnimationPlayer instead.

teodosiah and others added 2 commits November 12, 2026 11:46
The expansion panel, tree and stepper removed their collapsed content
only on the next render, after the animation player was reset or
destroyed. The content was then painted in place for a frame, e.g. in
zoneless applications.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@teodosiah teodosiah changed the title fix(expansion-panel): render collapse synchronously to avoid flicker fix(toggle-animation): remove collapsed content before animation reset Nov 12, 2026
@teodosiah
teodosiah requested a review from mddragnev November 12, 2026 12:28
@teodosiah
teodosiah requested a review from mddragnev November 13, 2026 07:55

@mddragnev mddragnev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@teodosiah I think you should backport this as well, right?

@viktorkombov viktorkombov added 💥 status: in-test PRs currently being tested and removed ❌ status: awaiting-test PRs awaiting manual verification labels Nov 13, 2026

@viktorkombov viktorkombov 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.

The fix works for the expansion panel, accordion, banner, tree and stepper. Found two problems, details inline:

  • a Next button inside a step's form no longer submits it (vertical fade/none, or noop animations);
  • the carousel can throw from the leave animation end and then doesn't destroy the leave player.
    The backports #17983 and #17984 have the same code.

if (type === ANIMATION_TYPE.CLOSE) {
// Render the collapsed state synchronously, so that the content is removed before resetting the player
// clears the animation styles; otherwise (e.g. zoneless) it is painted at full height for a frame.
this._toggleAnimationCdr?.detectChanges();

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.

A Next button inside a step's form no longer submits it, and a value with updateOn: 'submit' is lost (master is fine).
Setup: zoneless app (or zone.js with eventCoalescing); <igx-stepper orientation="vertical" verticalAnimationType="fade"> (or "none"); in the first step's igxStepContent: <form [formGroup]="form" (ngSubmit)="save()"><input formControlName="name"><button (click)="stepper.next()">Next</button></form>.
Steps: type a name → click Next → save() is not called and form.value.name stays empty. A document:click handler that checks el.contains(event.target) also sees this click as outside.
Why: without a close animation, onDoneHandler runs inside next(), so this detectChanges() removes the form and the clicked button while the click is still being dispatched. The same happens with provideNoopAnimations() for any orientation and animation type. Maybe render here only after a real close animation?

this.leaveAnimationDone.emit();
// Render the left item's state synchronously, so that e.g. its content is removed before destroying
// the player clears the animation styles; otherwise it is painted in place for a frame.
this.cdr.detectChanges();

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.

The carousel can throw from the leave animation end, and then the leave player is not destroyed (master is fine).
Setup: zoneless app; <igx-carousel> with @for (item of items(); track item.id) { <igx-slide>{{ item.title }}</igx-slide> } and <ng-template igxCarouselIndicator let-slide>{{ items()[slide.index].title }}</ng-template> (the carousel dev demo reads slides[slide.index] the same way).
Steps: carousel.next() → when the slide animation finishes (Promise.all(carouselElement.getAnimations({ subtree: true }).map(a => a.finished))), remove the slide that left from items() → TypeError: Cannot read properties of undefined (reading 'title').
Why: this detectChanges() renders the indicators with the old slides list before the app view is checked, and the error skips the destroy() below.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expansion panel, accordion, banner, stepper and tree flicker on collapse in zoneless apps

4 participants