KEMBAR78
fix: reflect row aria-expanded state for toggle cells by ugur-vaadin · Pull Request #10156 · vaadin/web-components · GitHub
Skip to content

Conversation

@ugur-vaadin
Copy link
Contributor

Description

When cell focus mode is active and the row is expanded/collapsed via Space key, the state change is not announced for NVDA and VoiceOver.

This PR reflects the row aria-expanded state to the toggle cells so that the announcements in cell focus mode works correctly.

Fixes #5791

Type of change

  • Bugfix
  • Feature

Checklist

  • I have read the contribution guide: https://vaadin.com/docs/latest/contributing/pr
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.

* @return {HTMLElement|null}
* @private
*/
__a11yFindTreeToggleCell(row) {
Copy link
Contributor

@vursen vursen Sep 15, 2025

Choose a reason for hiding this comment

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

Let's put this helper function into vaadin-grid-helpers.js since it doesn't depend on the class logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracted the function.

_a11yUpdateRowExpanded(row) {
if (this.__isRowExpandable(row)) {
row.setAttribute('aria-expanded', 'false');
const toggleCell = this.__a11yFindTreeToggleCell(row);
Copy link
Contributor

Choose a reason for hiding this comment

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

This variable could be created outside the branches to avoid duplication.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracted the line.

Co-authored-by: Sergey Vinogradov <mr.vursen@gmail.com>
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copy link
Contributor

@vursen vursen left a comment

Choose a reason for hiding this comment

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

Tested on Windows with NVDA – works correctly.

@DiegoCardoso
Copy link
Contributor

There's a behavior that I first thought was getting introduced by these changes, but it seems that it is the same when the changes are reverted (I simply made the helper function return null to make it easier to test). I tried to record it in the video below. Basically, after expanding one row, it starts to announce the other rows' expanded state. I don't know if I am not testing it properly or if this is the expected behavior. Could you guys double-check it? Tested on Safari + VO:

row-a11y.mp4

@vursen
Copy link
Contributor

vursen commented Sep 16, 2025

Basically, after expanding one row, it starts to announce the other rows' expanded state. I don't know if I am not testing it properly or if this is the expected behavior

I can confirm that as well.

@ugur-vaadin
Copy link
Contributor Author

It seems like that issue is browser-specific and does not reproduce on Chrome. In any case, it looks like a separate issue. I will create another one for that and merge this one if it makes sense @DiegoCardoso @vursen

@DiegoCardoso
Copy link
Contributor

Sounds good to me, especially if it's not related to this change. I wanted to mention it to confirm this finding.

@ugur-vaadin ugur-vaadin merged commit d70d60d into main Sep 16, 2025
8 of 9 checks passed
@ugur-vaadin ugur-vaadin deleted the refactor-reflect-row-aria-expanded-state-for-toggle-cells branch September 16, 2025 12:00
vaadin-bot pushed a commit that referenced this pull request Sep 16, 2025
* refactor: reflect row aria-expanded state for toggle cells

* refactor: get toggle cell once to avoid duplication

* refactor: extract logic for finding toggle cell into helper

* Update packages/grid/src/vaadin-grid-helpers.js

Co-authored-by: Sergey Vinogradov <mr.vursen@gmail.com>

---------

Co-authored-by: Sergey Vinogradov <mr.vursen@gmail.com>
vaadin-bot pushed a commit that referenced this pull request Sep 16, 2025
* refactor: reflect row aria-expanded state for toggle cells

* refactor: get toggle cell once to avoid duplication

* refactor: extract logic for finding toggle cell into helper

* Update packages/grid/src/vaadin-grid-helpers.js

Co-authored-by: Sergey Vinogradov <mr.vursen@gmail.com>

---------

Co-authored-by: Sergey Vinogradov <mr.vursen@gmail.com>
web-padawan pushed a commit that referenced this pull request Sep 17, 2025
Co-authored-by: Ugur Saglam <106508695+ugur-vaadin@users.noreply.github.com>
Co-authored-by: Sergey Vinogradov <mr.vursen@gmail.com>
web-padawan pushed a commit that referenced this pull request Sep 17, 2025
Co-authored-by: Ugur Saglam <106508695+ugur-vaadin@users.noreply.github.com>
Co-authored-by: Sergey Vinogradov <mr.vursen@gmail.com>
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 25.0.0-alpha12.

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.

TreeGrid expanded/collapsed status not announced by NVDA

4 participants