Skip to content

Conversation

DiegoCardoso
Copy link
Contributor

Description

Apply some adjustments to how the aria-rowcount/aria-colcount values are measured. The changes in this PR are:

  • Fix the wrong usage of headerRenderer at the method responsible of counting the number of footer rows
  • Add a call to _a11yUpdateGridSize in the __updateHeaderFooterRowVisibility method to recalculate the number of rows/cols when the renderers change
  • If empty-state is used and it's active, it is counted as a row
  • If the grid has no items and no header/footer is rendered, then the number of columns is adjusted accordingly

Below is a table with the possible states and how the amount of aria-rowcount and aria-colcount are reflected:

B: is the number of body rows, H of header rows, and F of footer rows

Body Rows Header Footer Empty State aria-rowcount aria-colcount
B + H + F # of cols in body
B + F # of cols in body
B + H # of cols in body
H + F # of cols in body
F # of cols in body
H # of cols in body
0 0
1 + H + F # of cols in body
1 + F # of cols in body
1 + H # of cols in body
1 1

Fixes #9081

Type of change

  • Bugfix

Apply some adjustments to how the `aria-rowcount`/`aria-colcount` values
are measured. The changes in this PR are:
- Fix the wrong usage of `headerRenderer` at the method responsible of
counting the number of footer rows
- Add a call to `_a11yUpdateGridSize` in the
`__updateHeaderFooterRowVisibility` method to recalculate the number of
rows/cols when the renderers change
- If empty-state is used and it's active, it is counted as a row
- If the grid has no items and no header/footer is rendered, then the
number of columns is adjusted accordingly

Fixes #9081
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes accessibility issues in the Grid component by correcting how aria-rowcount and aria-colcount values are calculated based on the grid's state, including header/footer visibility and empty state handling.

  • Fixed incorrect method call for counting footer rows (was using headerRenderer instead of footerRenderer)
  • Added grid size recalculation when header/footer visibility changes
  • Improved column count calculation to handle empty state scenarios appropriately

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/grid/src/vaadin-grid-a11y-mixin.js Fixed footer row counting bug and improved aria-rowcount/aria-colcount calculation logic with empty state support
packages/grid/src/vaadin-grid-mixin.js Added call to recalculate grid size when header/footer visibility changes
packages/grid/test/accessibility.test.js Added test cases to verify correct aria attribute values in various grid states

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
}

/** @private */
_a11yUpdateGridSize(size, _columnTree) {
_a11yUpdateGridSize(size, _columnTree, __emptyState) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_a11yUpdateGridSize(size, _columnTree, __emptyState) {
_a11yUpdateGridSize(size, _columnTree, emptyState) {

Copy link
Contributor Author

@DiegoCardoso DiegoCardoso Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 33c75a2.

@DiegoCardoso DiegoCardoso force-pushed the fix/grid/adjust-rolcount-colcount branch from f09c068 to 33c75a2 Compare August 4, 2025 09:18
Copy link

sonarqubecloud bot commented Aug 4, 2025

@web-padawan web-padawan merged commit 3f669d3 into main Aug 5, 2025
12 of 13 checks passed
@web-padawan web-padawan deleted the fix/grid/adjust-rolcount-colcount branch August 5, 2025 07:38
web-padawan pushed a commit that referenced this pull request Aug 5, 2025
… (#9891)

Co-authored-by: Diego Cardoso <diego@vaadin.com>
web-padawan pushed a commit that referenced this pull request Aug 5, 2025
… (#9892)

Co-authored-by: Diego Cardoso <diego@vaadin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[grid] Screen readers count the hidden footer rowgroup in the rows
5 participants