Skip to content

fix: add aria-pressed semantics to selectable Tag, remove default aria-pressed from InteractionTag #34619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add aria-pressed semantics to selectable Tag, remove default aria-pressed from InteractionTag",
"packageName": "@fluentui/react-tags",
"email": "sarah.higley@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const useTag_unstable = (props: TagProps, ref: React.Ref<HTMLSpanElement
appearance = contextAppearance ?? 'filled',
disabled = false,
dismissible = contextDismissible ?? false,
selected = false,
selected,
shape = 'rounded',
size = contextSize,
value = id,
Expand All @@ -62,14 +62,16 @@ export const useTag_unstable = (props: TagProps, ref: React.Ref<HTMLSpanElement
});

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

return {
appearance,
avatarShape: tagAvatarShapeMap[shape],
avatarSize: tagAvatarSizeMap[size],
disabled: contextDisabled ? true : disabled,
dismissible,
selected,
selected: !!selected,
shape,
size,

Expand All @@ -86,6 +88,7 @@ export const useTag_unstable = (props: TagProps, ref: React.Ref<HTMLSpanElement
getIntrinsicElementProps(elementType, {
ref,
role: tagGroupRole === 'listbox' ? 'option' : undefined,
[selectedProp]: selectable ? selected : undefined,
...props,
disabled: contextDisabled ? true : disabled,
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const tagGroupContextDefaultValue: TagGroupContextValue = {
handleTagDismiss: () => ({}),
size: 'medium',
role: 'toolbar',
handleTagSelect: () => ({}),
handleTagSelect: undefined,
};

/**
Expand Down
Loading