Skip to content

Commit 297da60

Browse files
authored
fix(ui5-table-growing): remember correct last row with Enter (#11361)
1 parent 002f64f commit 297da60

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ describe("TableGrowing - Button", () => {
151151
.should("have.been.calledTwice");
152152
});
153153

154-
it("tests focus is set to first newly added row", () => {
154+
it("tests focus is set to first newly added row - click", () => {
155155
cy.mount(<TableSample></TableSample>);
156156

157157
cy.get<TableGrowing>("[ui5-table-growing]")
@@ -175,6 +175,30 @@ describe("TableGrowing - Button", () => {
175175
.should("have.focus");
176176
});
177177

178+
it("tests focus is set to first newly added row - ENTER", () => {
179+
cy.mount(<TableSample></TableSample>);
180+
181+
cy.get<TableGrowing>("[ui5-table-growing]")
182+
.then(tableGrowing => {
183+
tableGrowing.get(0).addEventListener("load-more", () => {
184+
const table = document.getElementById("table");
185+
const row = document.createElement("ui5-table-row");
186+
row.id = "new-row";
187+
row.innerHTML = "<ui5-table-cell><ui5-label>Cell B</ui5-label></ui5-table-cell>";
188+
table!.appendChild(row);
189+
});
190+
})
191+
.trigger("keydown", { key: "Enter", code: "Enter", which: 13 });
192+
193+
cy.get("[ui5-table]")
194+
.children("ui5-table-row")
195+
.should("have.length", 2);
196+
197+
cy.get("#new-row")
198+
.should("exist")
199+
.should("have.focus");
200+
});
201+
178202
it("tests focus is set to growing button when no new rows are added", () => {
179203
cy.mount(<TableSample></TableSample>);
180204

packages/main/src/TableGrowing.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ class TableGrowing extends UI5Element implements ITableGrowing {
176176
onBeforeRendering(): void {
177177
this._observer?.disconnect();
178178
this._observer = undefined;
179-
this._currentLastRow = undefined;
180179
this._renderContent = this.hasGrowingComponent();
181180
this._invalidateTable();
182181
}

0 commit comments

Comments
 (0)