diff --git a/packages/main/cypress/specs/TableGrowing.cy.tsx b/packages/main/cypress/specs/TableGrowing.cy.tsx index 477dccb0c03b..d12aed3f5004 100644 --- a/packages/main/cypress/specs/TableGrowing.cy.tsx +++ b/packages/main/cypress/specs/TableGrowing.cy.tsx @@ -226,16 +226,34 @@ describe("TableGrowing - Scroll", () => { .should("be.visible"); cy.get("[ui5-table-growing]") - .then(tableGrowing => tableGrowing.get(0).addEventListener("load-more", cy.stub().as("loadMore"))); + .then(tableGrowing => { + tableGrowing.get(0).addEventListener("load-more", cy.stub().as("loadMore")); + tableGrowing.get(0).addEventListener("load-more", () => { + const table = document.getElementById("table"); + Array.from({ length: 10 }).forEach(() => { + const row = document.createElement("ui5-table-row"); + row.innerHTML = "Cell B"; + table!.appendChild(row); + }); + }); + }); - cy.get("[ui5-table-row]:last-child") + for (let i = 0; i <= 5; i++) { + cy.get("[ui5-table-row]:last-child") .scrollIntoView(); - cy.get("[ui5-table-row]:last-child") - .should("be.visible"); + cy.get("[ui5-table-row]:last-child") + .should("be.visible"); - cy.get("@loadMore") - .should("have.been.calledOnce"); + cy.get("@loadMore") + .should("have.been.calledOnce"); + + cy.get("#wrapper") + .then($wrapper => { + const wrapper = $wrapper.get(0); + expect(wrapper.scrollTop).to.be.greaterThan(0); + }); + } }); it("tests button fires load-more, button vanishes, scroll to end fires load-more", () => { @@ -282,6 +300,12 @@ describe("TableGrowing - Scroll", () => { cy.get("[ui5-table]") .children("ui5-table-row") .should("have.length", 1 + 10 * i); + + cy.get("#wrapper") + .then($wrapper => { + const wrapper = $wrapper.get(0); + expect(wrapper.scrollTop).to.be.greaterThan(0); + }); } }); }); diff --git a/packages/main/src/TableGrowing.ts b/packages/main/src/TableGrowing.ts index 076893d8a8b7..a4db1e78f682 100644 --- a/packages/main/src/TableGrowing.ts +++ b/packages/main/src/TableGrowing.ts @@ -197,8 +197,8 @@ class TableGrowing extends UI5Element implements ITableGrowing { // remembers the last row. only do this when the table has a growing component rendered. if (this._table && this.hasGrowingComponent()) { this._currentLastRow = this._table.rows[this._table.rows.length - 1]; + this._shouldFocusRow = true; } - this._shouldFocusRow = true; this.fireDecoratorEvent("load-more"); }