Skip to content

Conversation

tidy-dev
Copy link
Contributor

@tidy-dev tidy-dev commented Nov 25, 2024

Closes #19603

Description

When working on #19341, to make it so non-selectable list items could be browsed, I unintentionally made it so that selectable list items would take the same behavior. My mistake was seeing that the role of the list was still correct after changes.. but the actual list items now had role of listitem as opposed to option for non-presentational lists.

Screenshots

Commit list with correct role of listbox and items with role of option.
Commit list with correct role of list-box and items with role of `option

Commit unreachable list with correct role of list and items with role of listitem
Commit unreachable list with correct role of list and items with role of listitem

Showing item number on NVDA:
Shows a picture of desktop history commit list with the NVDA speechviewer open. The speech viewier shows that the list had been navigated and each item announced x of 100.

Release notes

Notes: [Fixed] Screen readers announce the position of the list items in selectable lists such as the history commit list.

@tidy-dev tidy-dev marked this pull request as ready for review November 25, 2024 15:07
@@ -499,7 +499,7 @@ export class CommitList extends React.Component<
{this.renderReorderCommitsHint()}
<List
ariaLabel="Commits"
role={this.props.isInformationalView === true ? 'list' : 'list-box'}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.. Not only did I goof on checking for undefined against an item that couldn't be undefined... but also I yes switched listbox to list-box (my malapropism acting up..). But it most definitely is listbox https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role

* 'option' because that have selection capability. In that case, a
* screenreader will only browse to the selected list option. If the list is
* meant to be informational as opposed for selection, we should use `list`
* with `listitem` as the role for the items so browse mode can navigate them.
*/
readonly role?: `option` | `listitem` | 'presentation'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also for some reason used backtick.. when it would more properly be a single quote... surprised the linter didn't hammer me on that.

@@ -1188,7 +1188,7 @@ export class List extends React.Component<IListProps, IListState> {
<ListRow
key={params.key}
id={id}
role={this.props.role === undefined ? undefined : 'listitem'}
Copy link
Contributor Author

@tidy-dev tidy-dev Nov 25, 2024

Choose a reason for hiding this comment

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

In ListRow the logic is:

sectionHasHeader && rowIndex.row === 0
            ? 'presentation'
            : role ?? 'option'

List logic:
role={this.props.role ?? 'listbox'}

So our two use cases are:

  1. CommitList which now does define a role as either list or listbox. (History or unreachable commit list)
  2. Every other list where role = undefined.

For every other, we want to keep current behavior as listbox and option. This does uphold, if role is undefined, the main grid is "defined or listbox", this logic here says undefined !== list so the ListBox will receive undefined. which will then filter through the sectionHeader logic to the same "definedRole or option".

For the CommitList, it will send in a defined role of list or listbox so it will pass that and set it on the main List. and this condition will say if it list to define a role for the list item as listitem otherwise do undefined which will again follow the above and use the default of option assuming it isn't a sectionHeader row.

@tidy-dev tidy-dev merged commit 8eadad2 into development Nov 26, 2024
7 checks passed
@tidy-dev tidy-dev deleted the fix-commit-list-numbering-regression branch November 26, 2024 12:09
@tidy-dev tidy-dev added the accessibility Issues related to accessibility improvements label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility Issues related to accessibility improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug Report: Missing Group Position Announcements in Commit List
2 participants