From 189e8a6b8a4ba7cabeefc288f929d8c631345ec4 Mon Sep 17 00:00:00 2001 From: Simon Selg Date: Tue, 23 Sep 2025 15:05:55 +0200 Subject: [PATCH 1/3] add ComboBox Story for ListBoxItem with aria-label This can be used to check whether the screen-reader announcement for option selections reads the correct label for each option, especially on mac, where there is a special codepath for this. --- .../stories/ComboBox.stories.tsx | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/react-aria-components/stories/ComboBox.stories.tsx b/packages/react-aria-components/stories/ComboBox.stories.tsx index b825b6dd721..4aa528a18bb 100644 --- a/packages/react-aria-components/stories/ComboBox.stories.tsx +++ b/packages/react-aria-components/stories/ComboBox.stories.tsx @@ -367,3 +367,25 @@ export function WithCreateOption() { ); } + +export const ComboBoxListBoxItemWithAriaLabel: ComboBoxStory = () => ( + + +
+ + +
+ + + Item Foo + Item Bar + Item Baz + + +
+); From 7e694f674f0a3b2bb07610eebac417137cf35895 Mon Sep 17 00:00:00 2001 From: Simon Selg Date: Tue, 23 Sep 2025 16:25:25 +0200 Subject: [PATCH 2/3] fix `CollectionBuilder` to handle `aria-label` correctly This commit ensures the aria-label prop from the ListItem is read into the corresponding attribute ElementNode --- packages/@react-aria/collections/src/Document.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/@react-aria/collections/src/Document.ts b/packages/@react-aria/collections/src/Document.ts index f7fb5f61d7c..b8379a4d69a 100644 --- a/packages/@react-aria/collections/src/Document.ts +++ b/packages/@react-aria/collections/src/Document.ts @@ -344,6 +344,7 @@ export class ElementNode extends BaseNode { node.rendered = rendered; node.render = render; node.value = value; + node['aria-label'] = obj['aria-label']; node.textValue = textValue || (typeof props.children === 'string' ? props.children : '') || obj['aria-label'] || ''; if (id != null && id !== node.key) { throw new Error('Cannot change the id of an item'); From 002423a93f2a54fb52faa75be342915476f1faa9 Mon Sep 17 00:00:00 2001 From: Robert Snow Date: Tue, 7 Oct 2025 06:40:47 +1100 Subject: [PATCH 3/3] only add key if it exists --- packages/@react-aria/collections/src/Document.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/@react-aria/collections/src/Document.ts b/packages/@react-aria/collections/src/Document.ts index b8379a4d69a..dd1dbeb4f36 100644 --- a/packages/@react-aria/collections/src/Document.ts +++ b/packages/@react-aria/collections/src/Document.ts @@ -344,7 +344,9 @@ export class ElementNode extends BaseNode { node.rendered = rendered; node.render = render; node.value = value; - node['aria-label'] = obj['aria-label']; + if (obj['aria-label']) { + node['aria-label'] = obj['aria-label']; + } node.textValue = textValue || (typeof props.children === 'string' ? props.children : '') || obj['aria-label'] || ''; if (id != null && id !== node.key) { throw new Error('Cannot change the id of an item');