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
16 changes: 5 additions & 11 deletions packages/@react-aria/listbox/src/useOption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {chain, filterDOMProps, isMac, isWebKit, mergeProps, useLinkProps, useSlotId} from '@react-aria/utils';
import {chain, filterDOMProps, mergeProps, useLinkProps, useSlotId} from '@react-aria/utils';
import {DOMAttributes, FocusableElement, Key, RefObject} from '@react-types/shared';
import {getItemCount} from '@react-stately/collections';
import {getItemId, listData} from './utils';
Expand Down Expand Up @@ -105,18 +105,12 @@ export function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: R
let optionProps = {
role: 'option',
'aria-disabled': isDisabled || undefined,
'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined
'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined,
'aria-label': props['aria-label'],
'aria-labelledby': labelId,
'aria-describedby': descriptionId
};

// Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply "text".
// We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.
// https://bugs.webkit.org/show_bug.cgi?id=209279
if (!(isMac() && isWebKit())) {
optionProps['aria-label'] = props['aria-label'];
optionProps['aria-labelledby'] = labelId;
optionProps['aria-describedby'] = descriptionId;
}

let item = state.collection.getItem(key);
if (isVirtualized) {
let index = Number(item?.index);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-aria-components/stories/ListBox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const ListBoxExample: ListBoxStory = (args) => (
<ListBox className={styles.menu} {...args} aria-label="test listbox">
<MyListBoxItem>Foo</MyListBoxItem>
<MyListBoxItem>Bar</MyListBoxItem>
<MyListBoxItem>Baz</MyListBoxItem>
<MyListBoxItem aria-label="Baz with custom label">Baz (Custom aria-label)</MyListBoxItem>
<MyListBoxItem href="http://google.com">Google</MyListBoxItem>
</ListBox>
);
Expand Down