Skip to content

Commit 3c076dd

Browse files
committed
fix(table): add a label for the checkboxes of individual rows
1 parent ad6e9c7 commit 3c076dd

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/components/table/table-selection.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ describe('table selection', () => {
3232
tableSelection = new TestTableSelection(
3333
() => table,
3434
new ElementPool(document),
35-
{ emit: emitSelect }
35+
{ emit: emitSelect },
36+
jest.fn((key: string) => key)
3637
);
3738
});
3839

src/components/table/table-selection.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ export class TableSelection {
2121
* @param getTable - Function that returns the Tabulator instance
2222
* @param pool - The element pool used to cache the checkbox components
2323
* @param selectEvent - The event emitter to use when checkboxes are toggled
24+
* @param getTranslation - Function to get translated strings
2425
*/
2526
constructor(
2627
private getTable: () => Tabulator,
2728
private pool: ElementPool,
28-
private selectEvent: EventEmitter<RowData[]>
29+
private selectEvent: EventEmitter<RowData[]>,
30+
private getTranslation: (key: string) => string
2931
) {
3032
this.selection = new Selection((index) =>
3133
getRowId(this.getRowByIndex(index).getData())
@@ -106,7 +108,9 @@ export class TableSelection {
106108
const element = this.pool.get(LIMEL_CHECKBOX);
107109
setElementProperties(element, {
108110
checked: this.selection.has(getRowId(cell.getData())),
111+
label: this.getTranslation('table.select-row'),
109112
});
113+
element.classList.add('hide-label');
110114
element.style.display = 'inline-block';
111115

112116
return element;

src/components/table/table.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,8 @@ export class Table {
477477
this.tableSelection = new TableSelection(
478478
() => this.tabulator,
479479
this.pool,
480-
this.select
480+
this.select,
481+
(key: string) => this.getTranslation(key)
481482
);
482483
this.tableSelection.setSelection(this.selection);
483484
}

0 commit comments

Comments
 (0)