Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/main/cypress/specs/Carousel.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,24 @@ describe("Carousel general interaction", () => {
});
});

it("_resizing remains false when navigateTo is called after _onResize", () => {
cy.mount(
<Carousel id="carousel">
<Button>Button 1</Button>
<Button>Button 2</Button>
<Button>Button 3</Button>
</Carousel>
);

cy.get<Carousel>("#carousel")
.then($carousel => {
const carousel = $carousel[0];
carousel._onResize();
carousel.navigateTo(2);
expect(carousel._resizing).to.be.false;
});
});

it("items should remain reachable after resizing increases items per page", () => {
const navigateStub = cy.stub().as("navigateStub");

Expand Down
2 changes: 2 additions & 0 deletions packages/main/src/Carousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,8 @@ class Carousel extends UI5Element {
return;
}

this._resizing = false;

this._currentPageIndex = newPageIndex;
this._updateVisibleItems(newPageIndex);

Expand Down
8 changes: 7 additions & 1 deletion packages/main/test/pages/CarouselPublicMethods.html
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,15 @@
<ui5-li icon="learning-assistant">Tutorials</ui5-li>
</ui5-list>
</ui5-card>

</ui5-carousel>
<ui5-button id="btnNavigate">Check animation after resize - navigate to 5</ui5-button>
</body>

<script>
const navigateLeftBtn = document.getElementById("navigateLeft");
const navigateRightBtn = document.getElementById("navigateRight");
const carousel = document.getElementById("carouselCards");
const btnNavigate = document.getElementById("btnNavigate");

navigateLeftBtn.addEventListener("click", function() {
const newPageIndex = carousel.visibleItemsIndices[0] - 1;
Expand All @@ -256,6 +257,11 @@
const newPageIndex = carousel.visibleItemsIndices[0] + 1;
carousel.navigateTo(newPageIndex);
});

btnNavigate.addEventListener("click", function() {
carousel._onResize();
carousel.navigateTo(5);
});
</script>

</html>
Loading