Skip to content

Dropdown menus - option selection : add aria-hidden on icons #1036

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: main
Choose a base branch
from

Conversation

Comete99
Copy link

@Comete99 Comete99 commented Jun 3, 2025

ajout aria-hidden sur les icônes + aria-selected pour le dropdown du document sharing

Issue associée : #967

@AntoLC AntoLC force-pushed the fix/967 branch 7 times, most recently from 02b616e to 8e7988b Compare June 11, 2025 15:00
@AntoLC AntoLC changed the title Dropdown menus - option selection : ajout aria-hidden sur les icônes Dropdown menus - option selection : add aria-hidden on icons Jul 18, 2025
mvarnier and others added 2 commits July 18, 2025 11:24
Add aria-hidden attribute to Icon component to
improve accessibility.
Add aria-label to DropdownMenu component when
selected.
Copy link
Collaborator

@Ovgodd Ovgodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, 👏
I just added a few suggestions (accessibility + minor DX).
everything else looks good!

@@ -41,7 +41,7 @@ export const DocShareModalFooter = ({
fullWidth={false}
onClick={copyDocLink}
color="tertiary"
icon={<span className="material-icons">add_link</span>}
icon={<Icon iconName="add_link" />}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
icon={<Icon iconName="add_link" />}
icon={<Icon iconName="add_link" aria-hidden="true" />}

@@ -14,6 +14,7 @@ export const Icon = ({
}: IconProps) => {
Copy link
Collaborator

@Ovgodd Ovgodd Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the Icon component more accessible by adding:

in the IconProps Type :
ariaLabel?: string;
ariaHidden?: boolean;
role?: string;

Suggested change
}: IconProps) => {
ariaLabel,
ariaHidden,
role,
}: IconProps) => {

Copy link
Collaborator

@Ovgodd Ovgodd Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick note: aria-hidden={!!!textProps['aria-label']} works but is a bit hard to read and not very flexible.

It might be cleaner to accept explicit ariaLabel, ariaHidden, and role props. That would make the intent clearer and help in cases where we want to force aria-hidden={false} (e.g. for selected items).

Happy to discuss it further if neededfeel free to reach out!

I’ll suggest a snippet below feel free to use it or adapt it as you see fit.

@@ -14,6 +14,7 @@ export const Icon = ({
}: IconProps) => {
return (
<Text
aria-hidden={!!!textProps['aria-label']}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
aria-hidden={!!!textProps['aria-label']}
aria-label={ariaLabel}
aria-hidden={computedAriaHidden}
role={computedRole}

@@ -14,6 +14,7 @@ export const Icon = ({
}: IconProps) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}: IconProps) => {
}: IconProps) => {
const computedAriaHidden = ariaHidden ?? !ariaLabel;
const computedRole = !computedAriaHidden ? role ?? 'img' : undefined;

/>
)}
<DropdownMenu options={options}>
<DropdownMenu options={options} label={t('Open the document options')}>
<IconOptions
isHorizontal
$theme="primary"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the DropdownMenu now has a label prop, the aria-label on IconOptions is no longer needed and creates redundancy. ( line 275 )

I'd suggest removing it and letting the menu handle accessibility.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally optional: you could create a variable like
const exportButtonLabel = 'Export the document'
to avoid repeating the string and make future changes easier.

Not a blocker at all, just a small DX improvement suggestion :)

@@ -18,7 +18,7 @@ test.describe('Doc Export', () => {
await createDoc(page, 'doc-editor', browserName, 1);
await page
.getByRole('button', {
name: 'download',
name: 'Export the document',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: 'Export the document',
name: exportButtonLabel,

).toBeHidden();

const memberCard = shareModal.getByLabel('List members card');
await expect(memberCard.getByText('test@accesses.test')).toBeVisible();
await expect(memberCard.getByLabel('doc-role-text')).toBeVisible();
await expect(
memberCard.getByRole('button', { name: 'more_horiz' }),
memberCard.getByRole('button', { name: 'Open the member options' }),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, extract into a variable if you'd like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants