Skip to content

Commit 7baabfa

Browse files
authored
fix(ui5-table): check select all checkbox, when all rows are selected programatically (#4455)
* fix(ui5-table): check select all checkbox, when all rows are selected programatically * remove change added by mistake * additional test added
1 parent 1416d42 commit 7baabfa

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

packages/main/src/Table.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const metadata = {
5151
propertyName: "rows",
5252
type: HTMLElement,
5353
individualSlots: true,
54+
invalidateOnChildChange: true,
5455
},
5556

5657
/**
@@ -434,6 +435,7 @@ class Table extends UI5Element {
434435
const columnSettings = this.getColumnPropagationSettings();
435436
const columnSettingsString = JSON.stringify(columnSettings);
436437
const rowsCount = this.rows.length;
438+
const selectedRows = this.selectedRows;
437439

438440
this.rows.forEach((row, index) => {
439441
if (row._columnsInfoString !== columnSettingsString) {
@@ -455,6 +457,8 @@ class Table extends UI5Element {
455457

456458
this._noDataDisplayed = !this.rows.length && !this.hideNoData;
457459
this.visibleColumnsCount = this.visibleColumns.length;
460+
461+
this._allRowsSelected = selectedRows.length === this.rows.length;
458462
}
459463

460464
onAfterRendering() {

packages/main/test/specs/Table.spec.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,36 @@ describe("Table general interaction", () => {
371371
assert.strictEqual(await selectionChangeCount.getProperty("value"), "5", "Enter key over an already selected row should trigger selection-change event");
372372
});
373373

374+
it("test selectAll functionallity in MultiSelect mode", async () => {
375+
await browser.url("http://localhost:8080/test-resources/pages/TableSelection.html");
376+
const firstRow = await browser.$("#firstRowMultiSelect");
377+
const secondRow = await browser.$("#secondRowMultiSelect");
378+
const thirdRow = await browser.$("#thirdRowMultiSelect");
379+
const forthRow = await browser.$("#forthRowMultiSelect");
380+
const table = await browser.$("#multi");
381+
const selectAllCheckBox = await table.shadow$("thead ui5-checkbox");
382+
383+
// act
384+
await firstRow.setProperty("selected", true);
385+
await secondRow.setProperty("selected", true);
386+
await thirdRow.setProperty("selected", true);
387+
await forthRow.setProperty("selected", true);
388+
389+
// assert
390+
assert.ok(await firstRow.getAttribute("selected"), "The first row is selected");
391+
assert.ok(await secondRow.getAttribute("selected"), "The second row is selected");
392+
assert.ok(await thirdRow.getAttribute("selected"), "The third row is selected");
393+
assert.ok(await forthRow.getAttribute("selected"), "The forth row is selected");
394+
assert.ok(await selectAllCheckBox.getProperty("checked"), "Select all checkbox is checked");
395+
396+
// act
397+
await forthRow.setProperty("selected", false);
398+
399+
// assert
400+
assert.notOk(await forthRow.getAttribute("selected"), "The forth row is not selected");
401+
assert.notOk(await selectAllCheckBox.getProperty("checked"), "Select all checkbox is not checked");
402+
});
403+
374404
it("test mouse and keyboard interaction over Active/Inactive row in Default mode", async () => {
375405
const table = await browser.$("#default");
376406
const firstRow = await browser.$("#firstRowDefaultMode");

0 commit comments

Comments
 (0)