-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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: Visual bugs when loading carousel with responsiveCarouselOptions #5166
Comments
I think your issue is similar to this one: #3985 |
I got this issue too (using Next.Js), |
Could be related to StrictMode? |
Nope. In my case, the bug still appears in dev mode with both strict and non-strict mode. |
Update: Turns out the bug is still there, but not in every scenario.
|
@melloware, I am able to reproduce same kind of issue using primereact 10.3.1 (we don't use React.StricMode). To make the 5 items appearing again, I need to resize browser manually -> calculatePosition() is called again thanks to useResizeListener(). |
PR is welcome @arnodemer |
Same problem. I ended up abandoning the responsiveOptions thing and make my own responsive implementation based on a custom hook returning preconfigured breakpoints on page resize. Since the Carousel does not refresh when updating the values of numVisible and numScroll props, I set a "reloading" state to true for 1 refresh just to return null and force component to refresh.
|
@melloware on createStyle function, after check props.responsiveOptions please add calculatePosition(); then it will fix this bug.
|
PR submitted @baonk |
Describe the bug
When loading the component for the first time, the page marker will have the incorrect number of pages, and moving to another page makes the elements disappear. Also, it skips the wrong amount of elements, instead of the defined numScroll, it will scroll by the number of elements in a page.
The problem disappears if the viewport width changes (by resizing the window or opening inspect window).
Reproducer
https://codesandbox.io/s/primereact-test-forked-2s7n95
PrimeReact version
10.0.7
React version
18.x
Language
TypeScript
Build / Runtime
Vite
Browser(s)
No response
Steps to reproduce the behavior
Expected behavior
Carousel should load the correct page count, and elements should move in the defined numScroll amount and elements should not disappear.
The text was updated successfully, but these errors were encountered: