Skip to content

Commit 002f64f

Browse files
authored
fix(ui5-table-growing): prevent focus while scroll to grow (#11358)
* fix(ui5-table-growing): focus while scroll to grow * test(ui5-table-growing): add scroll top check
1 parent f8e77cb commit 002f64f

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

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

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,34 @@ describe("TableGrowing - Scroll", () => {
226226
.should("be.visible");
227227

228228
cy.get<TableGrowing>("[ui5-table-growing]")
229-
.then(tableGrowing => tableGrowing.get(0).addEventListener("load-more", cy.stub().as("loadMore")));
229+
.then(tableGrowing => {
230+
tableGrowing.get(0).addEventListener("load-more", cy.stub().as("loadMore"));
231+
tableGrowing.get(0).addEventListener("load-more", () => {
232+
const table = document.getElementById("table");
233+
Array.from({ length: 10 }).forEach(() => {
234+
const row = document.createElement("ui5-table-row");
235+
row.innerHTML = "<ui5-table-cell><ui5-label>Cell B</ui5-label></ui5-table-cell>";
236+
table!.appendChild(row);
237+
});
238+
});
239+
});
230240

231-
cy.get("[ui5-table-row]:last-child")
241+
for (let i = 0; i <= 5; i++) {
242+
cy.get("[ui5-table-row]:last-child")
232243
.scrollIntoView();
233244

234-
cy.get("[ui5-table-row]:last-child")
235-
.should("be.visible");
245+
cy.get("[ui5-table-row]:last-child")
246+
.should("be.visible");
236247

237-
cy.get("@loadMore")
238-
.should("have.been.calledOnce");
248+
cy.get("@loadMore")
249+
.should("have.been.calledOnce");
250+
251+
cy.get("#wrapper")
252+
.then($wrapper => {
253+
const wrapper = $wrapper.get(0);
254+
expect(wrapper.scrollTop).to.be.greaterThan(0);
255+
});
256+
}
239257
});
240258

241259
it("tests button fires load-more, button vanishes, scroll to end fires load-more", () => {
@@ -282,6 +300,12 @@ describe("TableGrowing - Scroll", () => {
282300
cy.get("[ui5-table]")
283301
.children("ui5-table-row")
284302
.should("have.length", 1 + 10 * i);
303+
304+
cy.get("#wrapper")
305+
.then($wrapper => {
306+
const wrapper = $wrapper.get(0);
307+
expect(wrapper.scrollTop).to.be.greaterThan(0);
308+
});
285309
}
286310
});
287311
});

packages/main/src/TableGrowing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ class TableGrowing extends UI5Element implements ITableGrowing {
197197
// remembers the last row. only do this when the table has a growing component rendered.
198198
if (this._table && this.hasGrowingComponent()) {
199199
this._currentLastRow = this._table.rows[this._table.rows.length - 1];
200+
this._shouldFocusRow = true;
200201
}
201-
this._shouldFocusRow = true;
202202

203203
this.fireDecoratorEvent("load-more");
204204
}

0 commit comments

Comments
 (0)