Skip to content

ComboBox: aXe throws an error when the virtualized listbox is scrollable #4080

Open
@majornista

Description

🐛 Bug Report

While testing MobileComboBox variant that opens within a Tray using ComboBox example with many items example, aXe throws an error when the virtualized listbox is scrollable, Scrollable region must have keyboard access, because the listbox and any of its descendant option items do not have a tabIndex.

This relates to the following commit, which removes tabIndex from the listbox and descendant option items for virtualized listboxes that use aria-activedescendant: Remove tabIndex from listbox and options when using virtual focus: iOS 14 moves real DOM focus even with aria-activedescendant otherwise.

See the code comments for this behavior as well:

// Set tabIndex to 0 if the element is focused, or -1 otherwise so that only the last focused
// item is tabbable. If using virtual focus, don't set a tabIndex at all so that VoiceOver
// on iOS 14 doesn't try to move real DOM focus to the item anyway.
let itemProps: SelectableItemAria['itemProps'] = {};
if (!shouldUseVirtualFocus && !isDisabled) {
itemProps = {
tabIndex: key === manager.focusedKey ? 0 : -1,
onFocus(e) {
if (e.target === ref.current) {
manager.setFocusedKey(key);
}
}
};
} else if (isDisabled) {

and:

// If nothing is focused within the collection, make the collection itself tabbable.
// This will be marshalled to either the first or last item depending on where focus came from.
// If using virtual focus, don't set a tabIndex at all so that VoiceOver on iOS 14 doesn't try
// to move real DOM focus to the element anyway.
let tabIndex: number;
if (!shouldUseVirtualFocus) {
tabIndex = manager.focusedKey == null ? 0 : -1;
}

🤔 Expected Behavior

aXe should not throw this false positive on platforms where it is not necessary to remove the tabIndex.

😯 Current Behavior

aXe throws an error when the virtualized listbox is scrollable, Scrollable region must have keyboard access, because the listbox and any of its descendant option items do not have a tabIndex.

💁 Possible Solution

We might be able to safely remove the tabIndex attributes for a virtualized listbox only on mobile devices.

🔦 Context

Accessibility audit

🌍 Your Environment

Software Version(s)
react-spectrum @adobe/[email protected]
Browser Google Chrome Version 110.0.5481.77 (Official Build) (arm64)
Operating System macOS Ventura 13.2.1 (22D68)

🧢 Your Company/Team

Adobe/Accessibility

🕷 Tracking Issue (optional)

A11Y-5821

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions