Skip to content

Commit

Permalink
fix: prevent setting values on uninitialized field of the cms-carouse…
Browse files Browse the repository at this point in the history
…l.component (#1492)
  • Loading branch information
dhhyi authored Sep 5, 2023
1 parent a081c94 commit 8d3f6a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ngb-carousel
#ngbCarousel
[interval]="0"
[showNavigationArrows]="pageletSlides.length > 1"
[showNavigationArrows]="pageletSlides?.length > 1"
[showNavigationIndicators]="pagelet.booleanParam('ShowIndicators')"
>
<ng-template ngbSlide *ngFor="let slidePagelets of pageletSlides">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,21 @@ export class CMSCarouselComponent implements CMSComponent, OnChanges, OnDestroy
const slotPagelets = this.pagelet.slot('app_sf_base_cm:slot.carousel.items.pagelet2-Slot').pageletIDs;
this.pageletSlides = arraySlices(slotPagelets, this.slideItems);

this.appRef.isStable
.pipe(
whenTruthy(),
map(() => (this.pagelet.booleanParam('StartCycling') ? this.pagelet.numberParam('SlideInterval', 5000) : 0)),
take(1),
takeUntil(this.destroy$)
)
.subscribe(val => {
if (val) {
this.carousel.interval = val;
this.carousel.cycle();
}
});
if (!SSR) {
this.appRef.isStable
.pipe(
whenTruthy(),
map(() => (this.pagelet.booleanParam('StartCycling') ? this.pagelet.numberParam('SlideInterval', 5000) : 0)),
take(1),
takeUntil(this.destroy$)
)
.subscribe(val => {
if (val && this.carousel) {
this.carousel.interval = val;
this.carousel.cycle();
}
});
}
}

ngOnDestroy() {
Expand Down

0 comments on commit 8d3f6a1

Please sign in to comment.