Skip to content

Commit cf0ccd5

Browse files
GerganaKremenskaplamenivanov91
authored andcommitted
chore(ui5-carousel): restore incorrectly removed getter (UI5#12515)
* fix(ui5-carousel): add worngly removed getter * fix(ui5-carousel): added decorator to private property * fix(ui5-carousel): remove trailing space * fix(ui5-carousel): fixed test case
1 parent 7f19b31 commit cf0ccd5

File tree

2 files changed

+44
-11
lines changed

2 files changed

+44
-11
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,32 @@ describe("Carousel general interaction", () => {
389389

390390
});
391391

392+
it.only("navigateTo method and visibleItemsIndices", () => {
393+
cy.mount(
394+
<Carousel id="carousel9" itemsPerPage="S2 M2 L2 XL2" arrowsPlacement="Navigation">
395+
<Button>Button 1</Button>
396+
<Button>Button 2</Button>
397+
<Button>Button 3</Button>
398+
<Button>Button 4</Button>
399+
<Button>Button 5</Button>
400+
<Button>Button 6</Button>
401+
<Button>Button 7</Button>
402+
<Button>Button 8</Button>
403+
<Button>Button 9</Button>
404+
<Button>Button 10</Button>
405+
</Carousel>);
406+
407+
cy.get("#carousel9")
408+
.invoke("prop", "visibleItemsIndices")
409+
.should("deep.equal", [0, 1]);
410+
411+
cy.get("#carousel9").shadow().find('[data-ui5-arrow-forward="true"]').realClick();
412+
413+
cy.get("#carousel9")
414+
.invoke("prop", "visibleItemsIndices")
415+
.should("deep.equal", [1, 2]);
416+
});
417+
392418
it("F7 keyboard navigation", () => {
393419
cy.mount(
394420
<Carousel id="carouselF7" itemsPerPage="S3 M3 L3 XL3">

packages/main/src/Carousel.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,6 @@ class Carousel extends UI5Element {
184184
@property({ type: Boolean })
185185
hideNavigationArrows = false;
186186

187-
/**
188-
* Defines the current first visible item in the viewport.
189-
* Default value is 0, which means the first item in the viewport.
190-
*
191-
* @since 1.0.0-rc.15
192-
* @default 0
193-
* @public
194-
*/
195-
@property({ type: Number, noAttribute: true })
196-
_currentSlideIndex: number = 0;
197-
198187
/**
199188
* Defines the visibility of the page indicator.
200189
* If set to true the page indicator will be hidden.
@@ -288,6 +277,14 @@ class Carousel extends UI5Element {
288277
@property({ type: Boolean, noAttribute: true })
289278
_visibleNavigationArrows = false;
290279

280+
/**
281+
* Defines the current slide index, which contains the visible item in the viewport.
282+
* @private
283+
* @since 2.16.0-r.c1
284+
*/
285+
@property({ type: Number, noAttribute: true })
286+
_currentSlideIndex: number = 0;
287+
291288
_scrollEnablement: ScrollEnablement;
292289
_onResizeBound: ResizeObserverCallback;
293290
_resizing: boolean;
@@ -700,6 +697,16 @@ class Carousel extends UI5Element {
700697
this.focusItem();
701698
}
702699

700+
/**
701+
* The indices of the currently visible items of the component.
702+
* @public
703+
* @since 1.0.0-rc.15
704+
* @default []
705+
*/
706+
get visibleItemsIndices() : Array<number> {
707+
return this._visibleItemsIndexes;
708+
}
709+
703710
/**
704711
* Assuming that all items have the same width
705712
* @private

0 commit comments

Comments
 (0)