Repository navigation
fix(toggle-animation): remove collapsed content before animation reset #17965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
1e7d58c
0c6aa54
2a42ddb
0343f08
4ddb29d
9c15252
2257722
1692816
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { AnimationReferenceMetadata } from '@angular/animations'; | ||
| import { Directive, ElementRef, EventEmitter, inject, OnDestroy } from '@angular/core'; | ||
| import { ChangeDetectorRef, Directive, ElementRef, EventEmitter, inject, OnDestroy } from '@angular/core'; | ||
| import { noop, Subject } from 'rxjs'; | ||
| import { takeUntil } from 'rxjs/operators'; | ||
|
|
||
|
|
@@ -65,6 +65,12 @@ export abstract class ToggleAnimationPlayer implements ToggleAnimationOwner, OnD | |
| closeAnimation: growVerOut | ||
| }; | ||
|
|
||
| /** | ||
| * Renders the owner synchronously when its close animation is done. Optional, as the player can be | ||
| * created outside of a view, e.g. as a provider. | ||
| */ | ||
| private readonly _toggleAnimationCdr = inject(ChangeDetectorRef, { optional: true }); | ||
|
|
||
| private closeInterrupted = false; | ||
| private openInterrupted = false; | ||
|
|
||
|
|
@@ -151,6 +157,11 @@ export abstract class ToggleAnimationPlayer implements ToggleAnimationOwner, OnD | |
| if (!(type === ANIMATION_TYPE.OPEN ? this.openInterrupted : this.closeInterrupted)) { | ||
| targetEmitter.emit(); | ||
| } | ||
| 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(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| } | ||
| this.cleanUpPlayer(type); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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 readsslides[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 fromitems()→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 thedestroy()below.