Skip to content

fix(ui5-carousel): clamp page index when items per page changes on resize#13499

Merged
tsanislavgatev merged 1 commit into
mainfrom
carousel-fix
May 14, 2026
Merged

fix(ui5-carousel): clamp page index when items per page changes on resize#13499
tsanislavgatev merged 1 commit into
mainfrom
carousel-fix

Conversation

@tsanislavgatev
Copy link
Copy Markdown
Contributor

@tsanislavgatev tsanislavgatev commented May 11, 2026

When a user navigates forward in a Carousel and then resizes the browser so that effectiveItemsPerPage( increases to fit all items), the _currentPageIndex was not being re-adjusted. This caused earlier items to be shifted off-screen via the CSS translate3d transform, with no navigation arrows shown to scroll back — making those items permanently unreachable.

Root Cause
In _onResize(), when effectiveItemsPerPage changed, there was no clamping of _currentPageIndex to the new valid range [0, items.length - effectiveItemsPerPage]

Fix
Clamp _currentPageIndexto the valid range when effectiveItemsPerPage changes during resize
Fire the navigate event when the page index is adjusted (consistent with the event's documentation: "Fired whenever the page changes...while resizing")
Clamp _focusedItemIndex relative to the corrected page range
Testing
Added a Cypress test that:

Starts at M breakpoint (800px, 2 items/page) with 3 items
Navigates right to page index 1
Resizes to L breakpoint (1200px, 3 items/page)
Asserts page index is clamped to 0, all 3 items are visible, and the navigate event fires.

Fixes #13443

@tsanislavgatev tsanislavgatev requested a review from a team May 11, 2026 13:33
@ui5-webcomponents-bot
Copy link
Copy Markdown
Collaborator

ui5-webcomponents-bot commented May 11, 2026

🧹 Preview deployment cleaned up: https://pr-13499--ui5-webcomponents.netlify.app

@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview May 11, 2026 13:37 Inactive
@tsanislavgatev tsanislavgatev merged commit 851a63f into main May 14, 2026
20 of 21 checks passed
@tsanislavgatev tsanislavgatev deleted the carousel-fix branch May 14, 2026 11:26
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview May 14, 2026 11:26 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Carousel]: Items become unreachable after resizing

3 participants