Skip to content

Commit ac5cc48

Browse files
committed
refactor(carousel): move carousel context initialization to constructor
1 parent b37528c commit ac5cc48

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/components/carousel/carousel-slide.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,6 @@ export default class IgcCarouselSlideComponent extends LitElement {
4040

4141
private _carousel?: IgcCarouselComponent;
4242

43-
// Set carousel reference once provider is ready
44-
private readonly _context = createAsyncContext(
45-
this,
46-
carouselContext,
47-
(carousel) => {
48-
this._carousel = carousel;
49-
}
50-
);
51-
5243
protected get _index(): number {
5344
return this._carousel ? this._carousel.slides.indexOf(this) : 0;
5445
}
@@ -82,6 +73,15 @@ export default class IgcCarouselSlideComponent extends LitElement {
8273
@property({ type: Boolean, reflect: true })
8374
public previous = false;
8475

76+
constructor() {
77+
super();
78+
79+
// Set carousel reference once provider is ready (addresses Blazor timing issue)
80+
createAsyncContext(this, carouselContext, (carousel) => {
81+
this._carousel = carousel;
82+
});
83+
}
84+
8585
/**
8686
* @hidden @internal
8787
* @deprecated since 5.4.0. Use Carousel's `select` method instead.

0 commit comments

Comments
 (0)