Skip to content

Commit 09863d8

Browse files
authored
fix(ui5-table-row): announce entire row and columns (#2164)
Upon accessing the row, all cells and the respective columns they are within, should be announced in the following order: column - cell, column - cell, etc. FIXES: #2160
1 parent 66722b2 commit 09863d8

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

packages/main/src/Table.js

+1
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ class Table extends UI5Element {
296296
index,
297297
minWidth: column.minWidth,
298298
demandPopin: column.demandPopin,
299+
text: column.textContent,
299300
popinText: column.popinText,
300301
visible: !this._hiddenColumns[index],
301302
};

packages/main/src/TableRow.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
tabindex="{{_tabIndex}}"
44
@focusin="{{_onfocusin}}"
55
@click="{{_onrowclick}}"
6+
aria-label="{{ariaLabelText}}"
67
data-sap-focus-ref
78
part="row"
89
>

packages/main/src/TableRow.js

+26
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,32 @@ class TableRow extends UI5Element {
156156
get visibleCellsCount() {
157157
return this.visibleCells.length;
158158
}
159+
160+
get ariaLabelText() {
161+
return this.cells.map((cell, index) => {
162+
const columText = this.getColumnTextByIdx(index);
163+
const cellText = this.getCellText(cell);
164+
return `${columText} ${cellText}`;
165+
}).join(" ");
166+
}
167+
168+
getCellText(cell) {
169+
return this.getNormilzedTextContent(cell.textContent);
170+
}
171+
172+
getColumnTextByIdx(index) {
173+
const columnInfo = this._columnsInfo[index];
174+
175+
if (!columnInfo) {
176+
return "";
177+
}
178+
179+
return this.getNormilzedTextContent(columnInfo.text);
180+
}
181+
182+
getNormilzedTextContent(textContent) {
183+
return textContent.replace(/[\n\r\t]/g, "").trim();
184+
}
159185
}
160186

161187
TableRow.define();

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

+9
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,13 @@ describe("Table general interaction", () => {
5656
cellInRow2.click();
5757
assert.ok(lbl.getHTML().indexOf(row2Data), "Event rowClick fired and intercepted.");
5858
});
59+
60+
it("tests row aria-label value", () => {
61+
const row = browser.$("#roll-0").shadow$(".ui5-table-row-root");
62+
63+
const EXPECTED_TEXT = "Product Notebook Basic 15HT-1000 Supplier Very Best Screens Dimensions 30 x 18 x 3 cm Weight 4.2 KG Price 956 EUR";
64+
65+
assert.strictEqual(row.getAttribute("aria-label"), EXPECTED_TEXT,
66+
"The aria-label value is correct.");
67+
});
5968
});

0 commit comments

Comments
 (0)