Skip to content
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

Destroying (eg on switching page) with autoplay plugin causes error: Cannot read properties of undefined (reading 'stopOnInteraction') #643

Closed
2 tasks done
Tracked by #321
tombryden opened this issue Dec 2, 2023 · 10 comments · Fixed by #661
Labels
bug Something isn't working resolved This issue is resolved

Comments

@tombryden
Copy link

tombryden commented Dec 2, 2023

Bug is related to

  • embla-carousel-react
  • embla-carousel-autoplay

Embla Carousel version

  • v8.0.0-rc15

Describe the bug

Great work with this project!

Switching page (or destroying embla api) causes Cannot read properties of undefined (reading 'stopOnInteraction') when there are only a few elements in a carousel with the autoplay plugin. I am not sure what number of elements cause this problem - in our prod site, we are getting the error when displaying 4 slides while showing 4 at a time (flex: 0 0 25%). The example CodeSandbox shows this working with displaying 2 slides, and only having 2 slides in total, however failing with one slide with the same error.

In most cases our prod app carousels contain 5+ slides so no issues, however there are instances where 4 or less slides are being displayed in dynamically rendered carousels, causing this error.

CodeSandbox

https://codesandbox.io/p/github/tombryden/embla-autoplay-bug/main

Steps to reproduce

  1. Open CodeSandbox link above
  2. Click 'Another Page' hyperlink
  3. Observe Cannot read properties of undefined (reading 'stopOnInteraction') error.
  4. Uncomment slide 2
  5. Rerun above steps and observe no error

Expected behavior

Behaviour of the reproduction should be consistent between the two scenarios

@tombryden tombryden added the bug Something isn't working label Dec 2, 2023
@tombryden tombryden changed the title Destroying (and switching page) with Destroying (and switching page) with autoplay plugin causes error with reading stopOnInteraction Dec 2, 2023
@tombryden tombryden changed the title Destroying (and switching page) with autoplay plugin causes error with reading stopOnInteraction Destroying (and switching page) with autoplay plugin causes error: Cannot read properties of undefined (reading 'stopOnInteraction') Dec 2, 2023
@tombryden tombryden changed the title Destroying (and switching page) with autoplay plugin causes error: Cannot read properties of undefined (reading 'stopOnInteraction') Destroying (eg on switching page) with autoplay plugin causes error: Cannot read properties of undefined (reading 'stopOnInteraction') Dec 2, 2023
@davidjerleke
Copy link
Owner

Thanks @tombryden for a complete bug report. I'll look into it when I get the chance.

Best,
David

@ciza99
Copy link

ciza99 commented Dec 19, 2023

Are there any updates on this? or is this not happening in previous versions so I could temporarily downgrade?

@davidjerleke
Copy link
Owner

@ciza99 I haven’t had the time to look into it. You can try downgrading and see if that solves the problem but I don’t know that either at the time of writing.

@ciza99
Copy link

ciza99 commented Dec 19, 2023

@davidjerleke I can confirm that I have no issues on version v8.0.0-rc14

@davidjerleke
Copy link
Owner

Thanks @ciza99 for confirming!

@davidjerleke
Copy link
Owner

davidjerleke commented Dec 22, 2023

Hi @tombryden and @ciza99,

When I include embla-carousel-autoplay locally in your CodeSandbox it seems to work as expected. Try setting the NextJS option SWCminify: false so it uses terser instead, and let me know if the problem persists?

Best,
David

@davidjerleke davidjerleke added the awaiting response Issue is awaiting feedback label Dec 22, 2023
@tombryden
Copy link
Author

Hi @davidjerleke. Just tested including embla-carousel-autoplay locally which works as expected. Setting swcMinify: false still fails in NextJS 14.0.4 using the packaged version of autoplay. Thanks

@davidjerleke davidjerleke removed the awaiting response Issue is awaiting feedback label Dec 22, 2023
@davidjerleke
Copy link
Owner

@tombryden I found the culprit. A bug fix is on its way...

davidjerleke added a commit that referenced this issue Dec 22, 2023
davidjerleke added a commit that referenced this issue Dec 22, 2023
@davidjerleke davidjerleke added the resolved This issue is resolved label Dec 22, 2023
@davidjerleke
Copy link
Owner

@tombryden a bug fix for this was just released in v8.0.0-rc17.

@tombryden
Copy link
Author

@davidjerleke Many thanks!

@davidjerleke davidjerleke mentioned this issue Dec 23, 2023
37 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved This issue is resolved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants