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

[Bug]: useEmblaCarousel initializes Embla with stale options in certain cases #980

Closed
4 of 15 tasks
lesha1201 opened this issue Aug 21, 2024 · 6 comments · Fixed by #981
Closed
4 of 15 tasks

[Bug]: useEmblaCarousel initializes Embla with stale options in certain cases #980

lesha1201 opened this issue Aug 21, 2024 · 6 comments · Fixed by #981
Assignees
Labels
bug Something isn't working react Issue is related to React resolved This issue is resolved

Comments

@lesha1201
Copy link
Contributor

lesha1201 commented Aug 21, 2024

Which variants of Embla Carousel are you using?

  • embla-carousel (Core)
  • embla-carousel-react
  • embla-carousel-vue
  • embla-carousel-svelte
  • embla-carousel-autoplay
  • embla-carousel-auto-scroll
  • embla-carousel-solid
  • embla-carousel-auto-height
  • embla-carousel-class-names
  • embla-carousel-fade
  • embla-carousel-docs (Documentation)
  • embla-carousel-docs (Generator)

Steps to reproduce

The issues happens when useEmblaCarousel creates EmblaCarousel (emblaApi) at the same time when options have changed. It happens because of useEffect order

Here is an example: https://codesandbox.io/p/devbox/embla-carousel-stale-options-dw88yj

If you open the example on small viewport (less than 1024px in width) then the issue appears and Embla Carousel wrongly initialized with watchDrag: false instead of watchDrag: true.

Desktop.2024.08.21.-.17.57.47.01.mp4

Expected Behavior

Embla Carousel should be initialized with the latest options.

Additional Context

I have also tried...

What browsers are you seeing the problem on?

All browsers

Version

v8.2.0

CodeSandbox

https://codesandbox.io/p/devbox/embla-carousel-stale-options-dw88yj

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
  • I agree to follow this project's Contributing Guidelines for bug reports
@lesha1201 lesha1201 added the bug Something isn't working label Aug 21, 2024
@lesha1201
Copy link
Contributor Author

I will open PR shortly.

@davidjerleke
Copy link
Owner

@lesha1201 why aren’t you using the breakpoints option?

@lesha1201
Copy link
Contributor Author

lesha1201 commented Aug 21, 2024

@davidjerleke Didn't know about breakpoints options. Thanks for pointing it out.

However, the issue can happen in other cases where useEmblaCarousel starts initializing EmblaCarousel and at the same time the options have been changed. In this case, it will initialize it with the previous options.

@davidjerleke
Copy link
Owner

@lesha1201 thanks. I will look into this when possible.

@davidjerleke davidjerleke added the react Issue is related to React label Aug 25, 2024
@davidjerleke
Copy link
Owner

@lesha1201 thanks. Your PR solves the problem.

@davidjerleke davidjerleke added the resolved This issue is resolved label Aug 26, 2024
@davidjerleke davidjerleke reopened this Sep 2, 2024
@davidjerleke
Copy link
Owner

@lesha1201 this bug fix was released in v8.2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working react Issue is related to React resolved This issue is resolved
Projects
None yet
2 participants