Skip to content

fix(ui5-table-growing): prevent focus while scroll to grow #11358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 23, 2025
Merged
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
36 changes: 30 additions & 6 deletions packages/main/cypress/specs/TableGrowing.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,34 @@ describe("TableGrowing - Scroll", () => {
.should("be.visible");

cy.get<TableGrowing>("[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 = "<ui5-table-cell><ui5-label>Cell B</ui5-label></ui5-table-cell>";
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", () => {
Expand Down Expand Up @@ -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);
});
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/TableGrowing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
Loading