Skip to content

Commit af8b531

Browse files
authored
fix(module:segmented): should not block the selected$ if no animation (#9512)
1 parent b235309 commit af8b531

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

components/segmented/segmented-item.component.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import {
2121
ViewEncapsulation
2222
} from '@angular/core';
2323
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
24+
import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
25+
import { of } from 'rxjs';
2426
import { filter, map, switchMap, take, tap } from 'rxjs/operators';
2527

2628
import { NzIconModule } from 'ng-zorro-antd/icon';
@@ -70,6 +72,7 @@ import { NzSegmentedService } from './segmented.service';
7072
encapsulation: ViewEncapsulation.None
7173
})
7274
export class NzSegmentedItemComponent implements OnInit {
75+
private readonly animationType = inject(ANIMATION_MODULE_TYPE, { optional: true });
7376
private readonly service = inject(NzSegmentedService);
7477
private readonly elementRef = inject(ElementRef);
7578
private readonly destroyRef = inject(DestroyRef);
@@ -98,13 +101,16 @@ export class NzSegmentedItemComponent implements OnInit {
98101
this.service.activated$.next(this.elementRef.nativeElement);
99102
}
100103
}),
101-
switchMap(value =>
102-
this.service.animationDone$.pipe(
104+
switchMap(value => {
105+
if (this.animationType === 'NoopAnimations') {
106+
return of(value);
107+
}
108+
return this.service.animationDone$.pipe(
103109
filter(event => event.toState === 'to' || event.toState === 'toVertical'),
104110
take(1),
105111
map(() => value)
106-
)
107-
),
112+
);
113+
}),
108114
filter(value => value === this.nzValue()),
109115
takeUntilDestroyed(this.destroyRef)
110116
)

0 commit comments

Comments
 (0)