-
-
Notifications
You must be signed in to change notification settings - Fork 795
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
Carousel does not support dynamic content #1683
Comments
Hi @ben-half-helix, I think the issue you are reporting should have been fixed in #1605, but it hasn't been released yet. |
Thanks @alenaksu, are you able to confirm by testing locally? I can see you added a check for empty slides that would prevent the Also, do you know when to expect the release? |
@ben-half-helix not sure if this is related, but it's a gotcha a lot of folks aren't aware of. From MDN:
In other words, if you have slides like this: <sl-carousel>
<sl-carousel-item>
<!-- more elements here -->
</sl-carousel-item>
<sl-carousel-item>
<!-- more elements here -->
</sl-carousel-item>
</sl-carousel-item> The |
@claviska I did indeed review this when I saw |
2.11.1 has been released containing this fix. Please let us know if you have any trouble with it! |
@claviska This is great in that it resolves the issue that breaks the carousel when no slides are present on first render. I'm able to populate it based on dynamic data by using JS DOM API, however I've noticed you're using a
Which is referring to
|
2.11.2 has been released containing the fix in #1684. |
Confirming this fully resolves my bug report, it's now easy to populate the carousel with dynamic data. Thanks for the fast turnaround, exited to deploy this on fellowproducts.com! |
Describe the bug
The carousel component will not work unless the slides are present from the initial render. I can see there is a slotchange event listening for new slides being added/removed, but the initial render breaks if the slide length is 0 due to the
newActiveSlide
calculation resulting as NaN due to 0 % 0. Subsequently, once dynamic data gets added, the slotchange event does not appear to fire and re-trigger theinitializeSlides
method. This makes the component only usable for static content, and not, for example, content resulting from a data fetch.To Reproduce
Try slotting dynamic content into the component:
The carousel scrolling will be broken
The text was updated successfully, but these errors were encountered: