Skip to content

Commit 8e7988b

Browse files
mvarnierAntoLC
authored andcommitted
✨(feature) accessibility on Icon component
Add aria-hidden attribute to Icon component to improve accessibility. Add aria-label to DropdownMenu component when selected.
1 parent 4fc49d5 commit 8e7988b

File tree

7 files changed

+41
-13
lines changed

7 files changed

+41
-13
lines changed

src/frontend/apps/e2e/__tests__/app-impress/doc-export.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test.describe('Doc Export', () => {
1818
await createDoc(page, 'doc-editor', browserName, 1);
1919
await page
2020
.getByRole('button', {
21-
name: 'download',
21+
name: 'Export the document',
2222
})
2323
.click();
2424

@@ -75,7 +75,7 @@ test.describe('Doc Export', () => {
7575

7676
await page
7777
.getByRole('button', {
78-
name: 'download',
78+
name: 'Export the document',
7979
})
8080
.click();
8181

@@ -122,7 +122,7 @@ test.describe('Doc Export', () => {
122122

123123
await page
124124
.getByRole('button', {
125-
name: 'download',
125+
name: 'Export the document',
126126
})
127127
.click();
128128

@@ -186,7 +186,7 @@ test.describe('Doc Export', () => {
186186

187187
await page
188188
.getByRole('button', {
189-
name: 'download',
189+
name: 'Export the document',
190190
})
191191
.click();
192192

@@ -250,7 +250,7 @@ test.describe('Doc Export', () => {
250250

251251
await page
252252
.getByRole('button', {
253-
name: 'download',
253+
name: 'Export the document',
254254
})
255255
.click();
256256

@@ -294,7 +294,7 @@ test.describe('Doc Export', () => {
294294

295295
await page
296296
.getByRole('button', {
297-
name: 'download',
297+
name: 'Export the document',
298298
})
299299
.click();
300300

src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ test.describe('Doc Header', () => {
7070

7171
await expect(card.getByText('Owner ·')).toBeVisible();
7272
await expect(page.getByRole('button', { name: 'Share' })).toBeVisible();
73-
await expect(page.getByRole('button', { name: 'download' })).toBeVisible();
73+
await expect(
74+
page.getByRole('button', { name: 'Export the document' }),
75+
).toBeVisible();
7476
await expect(
7577
page.getByRole('button', { name: 'Open the document options' }),
7678
).toBeVisible();
@@ -143,7 +145,9 @@ test.describe('Doc Header', () => {
143145

144146
await goToGridDoc(page);
145147

146-
await expect(page.getByRole('button', { name: 'download' })).toBeVisible();
148+
await expect(
149+
page.getByRole('button', { name: 'Export the document' }),
150+
).toBeVisible();
147151

148152
await page.getByLabel('Open the document options').click();
149153

@@ -214,7 +218,9 @@ test.describe('Doc Header', () => {
214218

215219
await goToGridDoc(page);
216220

217-
await expect(page.getByRole('button', { name: 'download' })).toBeVisible();
221+
await expect(
222+
page.getByRole('button', { name: 'Export the document' }),
223+
).toBeVisible();
218224
await page.getByLabel('Open the document options').click();
219225

220226
await expect(page.getByLabel('Delete document')).toBeDisabled();
@@ -274,7 +280,9 @@ test.describe('Doc Header', () => {
274280

275281
await goToGridDoc(page);
276282

277-
await expect(page.getByRole('button', { name: 'download' })).toBeVisible();
283+
await expect(
284+
page.getByRole('button', { name: 'Export the document' }),
285+
).toBeVisible();
278286
await page.getByLabel('Open the document options').click();
279287

280288
await expect(page.getByLabel('Delete document')).toBeDisabled();

src/frontend/apps/impress/src/components/DropdownMenu.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { PropsWithChildren, useRef, useState } from 'react';
2+
import { useTranslation } from 'react-i18next';
23
import { css } from 'styled-components';
34

45
import { Box, BoxButton, BoxProps, DropButton, Icon, Text } from '@/components';
@@ -38,6 +39,7 @@ export const DropdownMenu = ({
3839
const { spacingsTokens, colorsTokens } = useCunninghamTheme();
3940
const [isOpen, setIsOpen] = useState(false);
4041
const blockButtonRef = useRef<HTMLDivElement>(null);
42+
const { t } = useTranslation();
4143

4244
const onOpenChange = (isOpen: boolean) => {
4345
setIsOpen(isOpen);
@@ -150,6 +152,7 @@ export const DropdownMenu = ({
150152
$direction="row"
151153
$align="center"
152154
$gap={spacingsTokens['base']}
155+
aria-selected={option.isSelected ? true : undefined}
153156
>
154157
{option.icon && (
155158
<Icon
@@ -164,7 +167,14 @@ export const DropdownMenu = ({
164167
</Text>
165168
</Box>
166169
{option.isSelected && (
167-
<Icon iconName="check" $size="20px" $theme="greyscale" />
170+
<Icon
171+
role="img"
172+
iconName="check"
173+
$size="20px"
174+
$theme="greyscale"
175+
aria-label={t('Checked')}
176+
aria-hidden="false"
177+
/>
168178
)}
169179
</BoxButton>
170180
);

src/frontend/apps/impress/src/components/Icon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const Icon = ({
1414
}: IconProps) => {
1515
return (
1616
<Text
17+
aria-hidden={!!!textProps['aria-label']}
1718
{...textProps}
1819
className={clsx('--docs--icon-bg', textProps.className, {
1920
'material-icons-filled': variant === 'filled',

src/frontend/apps/impress/src/features/docs/doc-header/components/DocToolBoxLicenceAGPL.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ export const DocToolBoxLicenceAGPL = ({
152152
setIsModalExportOpen(true);
153153
}}
154154
size={isSmallMobile ? 'small' : 'medium'}
155+
aria-label={t('Export the document')}
155156
/>
156157
)}
157158
<DropdownMenu options={options}>

src/frontend/apps/impress/src/features/docs/doc-share/components/DocShareModalFooter.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Button } from '@openfun/cunningham-react';
22
import { useTranslation } from 'react-i18next';
33
import { css } from 'styled-components';
44

5-
import { Box, HorizontalSeparator } from '@/components';
5+
import { Box, HorizontalSeparator, Icon } from '@/components';
66
import { Doc, useCopyDocLink } from '@/features/docs';
77

88
import { DocVisibility } from './DocVisibility';
@@ -36,7 +36,7 @@ export const DocShareModalFooter = ({ doc, onClose }: Props) => {
3636
fullWidth={false}
3737
onClick={copyDocLink}
3838
color="tertiary"
39-
icon={<span className="material-icons">add_link</span>}
39+
icon={<Icon iconName="add_link" />}
4040
>
4141
{t('Copy link')}
4242
</Button>

src/frontend/apps/impress/src/i18n/translations.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"Beautify": "Verschönern",
6363
"Can't load this page, please check your internet connection.": "Diese Seite kann nicht geladen werden. Bitte überprüfen Sie Ihre Internetverbindung.",
6464
"Cancel": "Abbrechen",
65+
"Checked": "Angehakt",
6566
"Close the modal": "Pop up schliessen",
6667
"Collaborate": "Zusammenarbeiten",
6768
"Collaborate and write in real time, without layout constraints.": "In Echtzeit und ohne Layout-Beschränkungen schreiben und zusammenarbeiten.",
@@ -253,6 +254,7 @@
253254
"Callout": "Destacado",
254255
"Can't load this page, please check your internet connection.": "No se puede cargar esta página, por favor compruebe su conexión a Internet.",
255256
"Cancel": "Cancelar",
257+
"Checked": "Marcado",
256258
"Close the modal": "Cerrar modal",
257259
"Collaborate": "Colabora",
258260
"Collaborate and write in real time, without layout constraints.": "Colaborar y escribir en tiempo real, sin restricciones de diseño.",
@@ -437,6 +439,7 @@
437439
"Callout": "Alerte",
438440
"Can't load this page, please check your internet connection.": "Impossible de charger cette page, veuillez vérifier votre connexion Internet.",
439441
"Cancel": "Annuler",
442+
"Checked": "Coché",
440443
"Close the modal": "Fermer la modale",
441444
"Collaborate": "Collaborer",
442445
"Collaborate and write in real time, without layout constraints.": "Collaborez et rédigez en temps réel, sans contrainte de mise en page.",
@@ -625,6 +628,7 @@
625628
"Beautify": "Filtro bellezza",
626629
"Can't load this page, please check your internet connection.": "Impossibile caricare questa pagina, controlla la tua connessione internet.",
627630
"Cancel": "Cancella",
631+
"Checked": "Selezionato",
628632
"Collaborate": "Collabora",
629633
"Collaborate and write in real time, without layout constraints.": "Collaborare e scrivere in tempo reale, senza vincoli di layout.",
630634
"Collaborative writing, Simplified.": "Scrittura collaborativa, semplificata.",
@@ -781,6 +785,7 @@
781785
"Beautify": "Maak mooier",
782786
"Can't load this page, please check your internet connection.": "Kan deze pagina niet laden. Controleer je internetverbinding.",
783787
"Cancel": "Breek af",
788+
"Checked": "Aangevinkt",
784789
"Close the modal": "Sluit het venster",
785790
"Collaborate": "Samenwerken",
786791
"Collaborate and write in real time, without layout constraints.": "Samenwerken en schrijven in realtime, zonder lay-out beperkingen.",
@@ -952,6 +957,7 @@
952957
"Anonymous": "Anonym",
953958
"Beautify": "Försköna",
954959
"Cancel": "Avbryt",
960+
"Checked": "Markerad",
955961
"Close the modal": "Stäng fönstret",
956962
"Convert Markdown": "Konvertera Markdown",
957963
"Correct": "Korrekt",
@@ -989,6 +995,7 @@
989995
"Banner image": "Afiş görseli",
990996
"Beautify": "Güzelleştir",
991997
"Cancel": "İptal",
998+
"Checked": "İşaretli",
992999
"Collaborate": "İşbirliği Yapın",
9931000
"Collaborate and write in real time, without layout constraints.": "Düzen kısıtlamaları olmadan gerçek zamanlı olarak işbirliği yapın ve yazın.",
9941001
"Collaborative writing, Simplified.": "İş birliğiyle yazmak çok daha Kolay.",
@@ -1078,6 +1085,7 @@
10781085
"Callout": "标注",
10791086
"Can't load this page, please check your internet connection.": "无法加载此页面,请检查您的网络连接。",
10801087
"Cancel": "取消",
1088+
"Checked": "已勾选",
10811089
"Close the modal": "关闭对话框",
10821090
"Collaborate": "协作",
10831091
"Collaborate and write in real time, without layout constraints.": "实时协作和写入,不受布局限制。",

0 commit comments

Comments
 (0)