fix(ui5-carousel): clamp page index when items per page changes on resize#13499
Merged
Conversation
Collaborator
|
🧹 Preview deployment cleaned up: https://pr-13499--ui5-webcomponents.netlify.app |
TeodorTaushanov
approved these changes
May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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