Skip to content

Commit 73fe253

Browse files
fix(ui5-carousel): fix navigateTo method (#13189)
* fix(ui5-carousel): fix navigateTo method * fix: fix navigation when cyclic=true * fix: fix focus issue and tests * chore: reorganize _changeSlideIndex method parameters
1 parent cac2899 commit 73fe253

File tree

4 files changed

+136
-172
lines changed

4 files changed

+136
-172
lines changed

packages/main/cypress/specs/Carousel.cy.tsx

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ describe("Carousel general interaction", () => {
394394

395395
});
396396

397-
it("navigateTo method and visibleItemsIndices", () => {
397+
it("navigateTo and _changeFocusIndex methods", () => {
398398
cy.mount(
399399
<Carousel id="carousel9" itemsPerPage="S2 M2 L2 XL2" arrowsPlacement="Navigation">
400400
<Button>Button 1</Button>
@@ -413,11 +413,50 @@ describe("Carousel general interaction", () => {
413413
.invoke("prop", "visibleItemsIndices")
414414
.should("deep.equal", [0, 1]);
415415

416-
cy.get("#carousel9").shadow().find('[data-ui5-arrow-forward="true"]').realClick();
416+
cy.get<Carousel>("#carousel9")
417+
.then($carousel => {
418+
$carousel[0].navigateTo(2);
419+
});
420+
421+
cy.get("#carousel9")
422+
.invoke("prop", "visibleItemsIndices")
423+
.should("deep.equal", [2, 3]);
424+
425+
cy.get<Carousel>("#carousel9")
426+
.then($carousel => {
427+
$carousel[0].navigateTo(3);
428+
});
429+
430+
cy.get("#carousel9")
431+
.invoke("prop", "visibleItemsIndices")
432+
.should("deep.equal", [3, 4]);
433+
434+
cy.get<Carousel>("#carousel9")
435+
.then($carousel => {
436+
$carousel[0]._changeFocusIndex(4);
437+
});
438+
439+
cy.get("#carousel9")
440+
.invoke("prop", "visibleItemsIndices")
441+
.should("deep.equal", [3, 4]);
442+
443+
cy.get<Carousel>("#carousel9")
444+
.then($carousel => {
445+
$carousel[0]._changeFocusIndex(5);
446+
});
417447

418448
cy.get("#carousel9")
419449
.invoke("prop", "visibleItemsIndices")
420-
.should("deep.equal", [1, 2]);
450+
.should("deep.equal", [4, 5]);
451+
452+
cy.get<Carousel>("#carousel9")
453+
.then($carousel => {
454+
$carousel[0].navigateTo(3);
455+
});
456+
457+
cy.get("#carousel9")
458+
.invoke("prop", "visibleItemsIndices")
459+
.should("deep.equal", [3, 4]);
421460
});
422461

423462
it("F7 keyboard navigation", () => {
@@ -518,8 +557,10 @@ describe("Carousel general interaction", () => {
518557
cy.get("#firstButton").realClick();
519558
cy.realPress("End");
520559
cy.get("#testHomeAndEnd").should("have.prop", "_focusedItemIndex", 9);
560+
cy.get("#testHomeAndEnd").should("have.prop", "_currentSlideIndex", 9);
521561
cy.realPress("Home");
522562
cy.get("#testHomeAndEnd").should("have.prop", "_focusedItemIndex", 0);
563+
cy.get("#testHomeAndEnd").should("have.prop", "_currentSlideIndex", 0);
523564
});
524565

525566
it("'PageUp' and 'PageDown' button press", () => {
@@ -551,16 +592,22 @@ describe("Carousel general interaction", () => {
551592

552593
cy.get("#firstButton").realClick();
553594
cy.get("#testPageUpDown").should("have.prop", "_focusedItemIndex", 0);
595+
cy.get("#testPageUpDown").should("have.prop", "_currentSlideIndex", 0);
554596
cy.realPress("PageUp");
555597
cy.get("#testPageUpDown").should("have.prop", "_focusedItemIndex", 10);
598+
cy.get("#testPageUpDown").should("have.prop", "_currentSlideIndex", 10);
556599
cy.realPress("PageUp");
557600
cy.get("#testPageUpDown").should("have.prop", "_focusedItemIndex", 20);
601+
cy.get("#testPageUpDown").should("have.prop", "_currentSlideIndex", 19);
558602
cy.realPress("PageUp");
559603
cy.get("#testPageUpDown").should("have.prop", "_focusedItemIndex", 21);
604+
cy.get("#testPageUpDown").should("have.prop", "_currentSlideIndex", 19);
560605
cy.realPress("PageDown");
561-
cy.get("#testPageUpDown").should("have.prop", "_focusedItemIndex", 11);
606+
cy.get("#testPageUpDown").should("have.prop", "_focusedItemIndex", 9);
607+
cy.get("#testPageUpDown").should("have.prop", "_currentSlideIndex", 9);
562608
cy.realPress("PageDown");
563-
cy.get("#testPageUpDown").should("have.prop", "_focusedItemIndex", 1);
609+
cy.get("#testPageUpDown").should("have.prop", "_focusedItemIndex", 0);
610+
cy.get("#testPageUpDown").should("have.prop", "_currentSlideIndex", 0);
564611
cy.realPress("PageDown");
565612
cy.get("#testPageUpDown").should("have.prop", "_focusedItemIndex", 0);
566613
});

0 commit comments

Comments
 (0)