Skip to content

Commit ea2fbd6

Browse files
authored
fix: add aria-pressed semantics to selectable Tag, remove default aria-pressed from InteractionTag (#34619)
1 parent c847809 commit ea2fbd6

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "fix: add aria-pressed semantics to selectable Tag, remove default aria-pressed from InteractionTag",
4+
"packageName": "@fluentui/react-tags",
5+
"email": "sarah.higley@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

packages/react-components/react-tags/library/src/components/Tag/useTag.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const useTag_unstable = (props: TagProps, ref: React.Ref<HTMLSpanElement
4141
appearance = contextAppearance ?? 'filled',
4242
disabled = false,
4343
dismissible = contextDismissible ?? false,
44-
selected = false,
44+
selected,
4545
shape = 'rounded',
4646
size = contextSize,
4747
value = id,
@@ -62,14 +62,16 @@ export const useTag_unstable = (props: TagProps, ref: React.Ref<HTMLSpanElement
6262
});
6363

6464
const elementType = dismissible ? 'button' : 'span';
65+
const selectedProp = tagGroupRole === 'listbox' ? 'aria-selected' : 'aria-pressed';
66+
const selectable = typeof selected === 'boolean' || tagGroupRole === 'listbox';
6567

6668
return {
6769
appearance,
6870
avatarShape: tagAvatarShapeMap[shape],
6971
avatarSize: tagAvatarSizeMap[size],
7072
disabled: contextDisabled ? true : disabled,
7173
dismissible,
72-
selected,
74+
selected: !!selected,
7375
shape,
7476
size,
7577

@@ -86,6 +88,7 @@ export const useTag_unstable = (props: TagProps, ref: React.Ref<HTMLSpanElement
8688
getIntrinsicElementProps(elementType, {
8789
ref,
8890
role: tagGroupRole === 'listbox' ? 'option' : undefined,
91+
[selectedProp]: selectable ? selected : undefined,
8992
...props,
9093
disabled: contextDisabled ? true : disabled,
9194
id,

packages/react-components/react-tags/library/src/contexts/tagGroupContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const tagGroupContextDefaultValue: TagGroupContextValue = {
77
handleTagDismiss: () => ({}),
88
size: 'medium',
99
role: 'toolbar',
10-
handleTagSelect: () => ({}),
10+
handleTagSelect: undefined,
1111
};
1212

1313
/**

0 commit comments

Comments
 (0)