Skip to content
Open
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
54 changes: 27 additions & 27 deletions packages/grid/src/vaadin-grid-a11y-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,67 +22,67 @@ export const A11yMixin = (superClass) =>
};
}
static get observers() {
return ['_a11yUpdateGridSize(size, _columnTree)'];
return ['__a11yUpdateGridSize(size, _columnTree)'];
}

/** @private */
_a11yGetHeaderRowCount(_columnTree) {
__a11yGetHeaderRowCount(_columnTree) {
return _columnTree.filter((level) =>
level.some((col) => col.headerRenderer || (col.path && col.header !== null) || col.header),
).length;
}

/** @private */
_a11yGetFooterRowCount(_columnTree) {
__a11yGetFooterRowCount(_columnTree) {
return _columnTree.filter((level) => level.some((col) => col.headerRenderer)).length;
}

/** @private */
_a11yUpdateGridSize(size, _columnTree) {
__a11yUpdateGridSize(size, _columnTree) {
if (size === undefined || _columnTree === undefined) {
return;
}

const bodyColumns = _columnTree[_columnTree.length - 1];
this.$.table.setAttribute(
'aria-rowcount',
size + this._a11yGetHeaderRowCount(_columnTree) + this._a11yGetFooterRowCount(_columnTree),
size + this.__a11yGetHeaderRowCount(_columnTree) + this.__a11yGetFooterRowCount(_columnTree),
);
this.$.table.setAttribute('aria-colcount', (bodyColumns && bodyColumns.length) || 0);

this._a11yUpdateHeaderRows();
this._a11yUpdateFooterRows();
this.__a11yUpdateHeaderRows();
this.__a11yUpdateFooterRows();
}

/** @protected */
_a11yUpdateHeaderRows() {
/** @private */
__a11yUpdateHeaderRows() {
iterateChildren(this.$.header, (headerRow, index) => {
headerRow.setAttribute('aria-rowindex', index + 1);
});
}

/** @protected */
_a11yUpdateFooterRows() {
/** @private */
__a11yUpdateFooterRows() {
iterateChildren(this.$.footer, (footerRow, index) => {
footerRow.setAttribute('aria-rowindex', this._a11yGetHeaderRowCount(this._columnTree) + this.size + index + 1);
footerRow.setAttribute('aria-rowindex', this.__a11yGetHeaderRowCount(this._columnTree) + this.size + index + 1);
});
}

/**
* @param {!HTMLElement} row
* @param {number} index
* @protected
* @private
*/
_a11yUpdateRowRowindex(row, index) {
row.setAttribute('aria-rowindex', index + this._a11yGetHeaderRowCount(this._columnTree) + 1);
__a11yUpdateRowRowindex(row, index) {
row.setAttribute('aria-rowindex', index + this.__a11yGetHeaderRowCount(this._columnTree) + 1);
}

/**
* @param {!HTMLElement} row
* @param {boolean} selected
* @protected
* @private
*/
_a11yUpdateRowSelected(row, selected) {
__a11yUpdateRowSelected(row, selected) {
// Jaws reads selection only for rows, NVDA only for cells
row.setAttribute('aria-selected', Boolean(selected));
iterateRowCells(row, (cell) => {
Expand All @@ -92,9 +92,9 @@ export const A11yMixin = (superClass) =>

/**
* @param {!HTMLElement} row
* @protected
* @private
*/
_a11yUpdateRowExpanded(row) {
__a11yUpdateRowExpanded(row) {
if (this.__isRowExpandable(row)) {
row.setAttribute('aria-expanded', 'false');
} else if (this.__isRowCollapsible(row)) {
Expand All @@ -107,9 +107,9 @@ export const A11yMixin = (superClass) =>
/**
* @param {!HTMLElement} row
* @param {number} level
* @protected
* @private
*/
_a11yUpdateRowLevel(row, level) {
__a11yUpdateRowLevel(row, level) {
// Set level for the expandable rows itself, and all the nested rows.
if (level > 0 || this.__isRowCollapsible(row) || this.__isRowExpandable(row)) {
row.setAttribute('aria-level', level + 1);
Expand All @@ -121,9 +121,9 @@ export const A11yMixin = (superClass) =>
/**
* @param {!HTMLElement} row
* @param {!HTMLElement} detailsCell
* @protected
* @private
*/
_a11ySetRowDetailsCell(row, detailsCell) {
__a11ySetRowDetailsCell(row, detailsCell) {
iterateRowCells(row, (cell) => {
if (cell !== detailsCell) {
cell.setAttribute('aria-controls', detailsCell.id);
Expand All @@ -134,14 +134,14 @@ export const A11yMixin = (superClass) =>
/**
* @param {!HTMLElement} row
* @param {number} colspan
* @protected
* @private
*/
_a11yUpdateCellColspan(cell, colspan) {
__a11yUpdateCellColspan(cell, colspan) {
cell.setAttribute('aria-colspan', Number(colspan));
}

/** @protected */
_a11yUpdateSorters() {
/** @private */
__a11yUpdateSorters() {
Array.from(this.querySelectorAll('vaadin-grid-sorter')).forEach((sorter) => {
let cellContent = sorter.parentNode;
while (cellContent && cellContent.localName !== 'vaadin-grid-cell-content') {
Expand Down
4 changes: 2 additions & 2 deletions packages/grid/src/vaadin-grid-column-group-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,13 @@ export const GridColumnGroupMixin = (superClass) =>
if (headerCell) {
headerCell.setAttribute('colspan', colSpan);
if (this._grid) {
this._grid._a11yUpdateCellColspan(headerCell, colSpan);
this._grid.__a11yUpdateCellColspan(headerCell, colSpan);
}
}
if (footerCell) {
footerCell.setAttribute('colspan', colSpan);
if (this._grid) {
this._grid._a11yUpdateCellColspan(footerCell, colSpan);
this._grid.__a11yUpdateCellColspan(footerCell, colSpan);
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions packages/grid/src/vaadin-grid-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ export const GridMixin = (superClass) =>
row.appendChild(detailsCell);
// Cache the details cell reference
row.__detailsCell = detailsCell;
this._a11ySetRowDetailsCell(row, detailsCell);
this.__a11ySetRowDetailsCell(row, detailsCell);
detailsCell._vacant = false;
}

Expand Down Expand Up @@ -644,7 +644,7 @@ export const GridMixin = (superClass) =>

this._updateRowOrderParts(row, index);

this._a11yUpdateRowRowindex(row, index);
this.__a11yUpdateRowRowindex(row, index);

this.__ensureRowItem(row);
this.__ensureRowHierarchy(row);
Expand Down Expand Up @@ -738,8 +738,8 @@ export const GridMixin = (superClass) =>
this._frozenCellsChanged();
this._updateFirstAndLastColumn();
this._resetKeyboardNavigation();
this._a11yUpdateHeaderRows();
this._a11yUpdateFooterRows();
this.__a11yUpdateHeaderRows();
this.__a11yUpdateFooterRows();
this.generateCellClassNames();
this.generateCellPartNames();
this.__updateHeaderAndFooter();
Expand Down Expand Up @@ -784,8 +784,8 @@ export const GridMixin = (superClass) =>

this._toggleDetailsCell(row, model.detailsOpened);

this._a11yUpdateRowLevel(row, model.level);
this._a11yUpdateRowSelected(row, model.selected);
this.__a11yUpdateRowLevel(row, model.level);
this.__a11yUpdateRowSelected(row, model.selected);

this._updateRowStateParts(row, model);

Expand All @@ -806,7 +806,7 @@ export const GridMixin = (superClass) =>

this._updateDetailsCellHeight(row);

this._a11yUpdateRowExpanded(row, model.expanded);
this.__a11yUpdateRowExpanded(row, model.expanded);
}

/** @private */
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/src/vaadin-grid-sort-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const SortMixin = (superClass) =>
this.__debounceClearCache();
}

this._a11yUpdateSorters();
this.__a11yUpdateSorters();

this._previousSorters = this._mapSorters();
}
Expand Down