Skip to content
Closed
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
22 changes: 22 additions & 0 deletions packages/main/cypress/specs/Carousel.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -777,4 +777,26 @@ describe("Carousel general interaction", () => {

cy.get("#outsideButton").should("be.focused");
});

it("visibleItemsIndices should not contain negative values when initial items < itemsPerPage", () => {
cy.mount(
<Carousel id="dynamicCarousel" itemsPerPage="S1 M2 L3 XL4">
<Card>Card 1</Card>
<Card>Card 2</Card>
</Carousel>
);

cy.viewport(1200, 500);

cy.get("#dynamicCarousel")
.shadow()
.find(".ui5-carousel-item:not(.ui5-carousel-item--hidden)")
.should("have.length", 2);

cy.get<Carousel>("#dynamicCarousel")
.then($carousel => {
const indices = $carousel[0].visibleItemsIndices;
expect(indices.every(i => i >= 0), "visibleItemsIndices should not contain negative values").to.be.true;
});
});
});
2 changes: 1 addition & 1 deletion packages/main/src/Carousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ class Carousel extends UI5Element {
}

if (newItemIndex > items.length - effectiveItemsPerPage) {
newItemIndex = items.length - effectiveItemsPerPage;
newItemIndex = Math.max(0, items.length - effectiveItemsPerPage);
}
const lastItemIndex = newItemIndex + effectiveItemsPerPage;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@import "../base/Breadcrumbs-parameters.css";
@import "./Button-parameters.css";
@import "../base/ButtonBadge-parameters.css";
@import "./BusyIndicator-parameters.css";
@import "../base/CalendarLegend-parameters.css";
@import "../base/CalendarLegendItem-parameters.css";
@import "./CalendarHeader-parameters.css";
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
@import "../base/Breadcrumbs-parameters.css";
@import "./Button-parameters.css";
@import "../base/ButtonBadge-parameters.css";
@import "./BusyIndicator-parameters.css";
@import "../base/CalendarLegend-parameters.css";
@import "../base/CalendarLegendItem-parameters.css";
@import "./CalendarHeader-parameters.css";
Expand Down
Loading