Skip to content

Commit fc491e6

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 ac0c16a commit fc491e6

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

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

7272
await page
7373
.getByRole('button', {
74-
name: 'download',
74+
name: 'Export the document',
7575
exact: true,
7676
})
7777
.click();
@@ -121,7 +121,7 @@ test.describe('Doc Export', () => {
121121

122122
await page
123123
.getByRole('button', {
124-
name: 'download',
124+
name: 'Export the document',
125125
exact: true,
126126
})
127127
.click();
@@ -189,7 +189,7 @@ test.describe('Doc Export', () => {
189189

190190
await page
191191
.getByRole('button', {
192-
name: 'download',
192+
name: 'Export the document',
193193
})
194194
.click();
195195

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

267267
await page
268268
.getByRole('button', {
269-
name: 'download',
269+
name: 'Export the document',
270270
})
271271
.click();
272272

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

317317
await page
318318
.getByRole('button', {
319-
name: 'download',
319+
name: 'Export the document',
320320
exact: true,
321321
})
322322
.click();

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
@@ -45,7 +45,9 @@ test.describe('Doc Header', () => {
4545

4646
await expect(card.getByText('Owner ·')).toBeVisible();
4747
await expect(page.getByRole('button', { name: 'Share' })).toBeVisible();
48-
await expect(page.getByRole('button', { name: 'download' })).toBeVisible();
48+
await expect(
49+
page.getByRole('button', { name: 'Export the document' }),
50+
).toBeVisible();
4951
await expect(
5052
page.getByRole('button', { name: 'Open the document options' }),
5153
).toBeVisible();
@@ -116,7 +118,9 @@ test.describe('Doc Header', () => {
116118

117119
await goToGridDoc(page);
118120

119-
await expect(page.getByRole('button', { name: 'download' })).toBeVisible();
121+
await expect(
122+
page.getByRole('button', { name: 'Export the document' }),
123+
).toBeVisible();
120124

121125
await page.getByLabel('Open the document options').click();
122126

@@ -186,7 +190,9 @@ test.describe('Doc Header', () => {
186190

187191
await goToGridDoc(page);
188192

189-
await expect(page.getByRole('button', { name: 'download' })).toBeVisible();
193+
await expect(
194+
page.getByRole('button', { name: 'Export the document' }),
195+
).toBeVisible();
190196
await page.getByLabel('Open the document options').click();
191197

192198
await expect(page.getByLabel('Delete document')).toBeDisabled();
@@ -246,7 +252,9 @@ test.describe('Doc Header', () => {
246252

247253
await goToGridDoc(page);
248254

249-
await expect(page.getByRole('button', { name: 'download' })).toBeVisible();
255+
await expect(
256+
page.getByRole('button', { name: 'Export the document' }),
257+
).toBeVisible();
250258
await page.getByLabel('Open the document options').click();
251259

252260
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,5 +1,6 @@
11
import { HorizontalSeparator } from '@gouvfr-lasuite/ui-kit';
22
import { Fragment, PropsWithChildren, useRef, useState } from 'react';
3+
import { useTranslation } from 'react-i18next';
34
import { css } from 'styled-components';
45

56
import { Box, BoxButton, BoxProps, DropButton, Icon, Text } from '@/components';
@@ -45,6 +46,7 @@ export const DropdownMenu = ({
4546
const { spacingsTokens, colorsTokens } = useCunninghamTheme();
4647
const [isOpen, setIsOpen] = useState(false);
4748
const blockButtonRef = useRef<HTMLDivElement>(null);
49+
const { t } = useTranslation();
4850

4951
const onOpenChange = (isOpen: boolean) => {
5052
setIsOpen(isOpen);
@@ -162,6 +164,7 @@ export const DropdownMenu = ({
162164
$direction="row"
163165
$align="center"
164166
$gap={spacingsTokens['base']}
167+
aria-selected={option.isSelected ? true : undefined}
165168
>
166169
{option.icon && (
167170
<Icon
@@ -177,7 +180,14 @@ export const DropdownMenu = ({
177180
</Box>
178181
{(option.isSelected ||
179182
selectedValues?.includes(option.value ?? '')) && (
180-
<Icon iconName="check" $size="20px" $theme="greyscale" />
183+
<Icon
184+
role="img"
185+
iconName="check"
186+
$size="20px"
187+
$theme="greyscale"
188+
aria-label={t('Checked')}
189+
aria-hidden="false"
190+
/>
181191
)}
182192
</BoxButton>
183193
{option.showSeparator && (

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/DocToolBox.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ export const DocToolBox = ({ doc }: DocToolBoxProps) => {
252252
setIsModalExportOpen(true);
253253
}}
254254
size={isSmallMobile ? 'small' : 'medium'}
255+
aria-label={t('Export the document')}
255256
/>
256257
)}
257258
<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 '@/docs/doc-management';
77

88
import { DocVisibility } from './DocVisibility';
@@ -41,7 +41,7 @@ export const DocShareModalFooter = ({
4141
fullWidth={false}
4242
onClick={copyDocLink}
4343
color="tertiary"
44-
icon={<span className="material-icons">add_link</span>}
44+
icon={<Icon iconName="add_link" />}
4545
>
4646
{t('Copy link')}
4747
</Button>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"Beautify": "Verschönern",
6262
"Can't load this page, please check your internet connection.": "Diese Seite kann nicht geladen werden. Bitte überprüfen Sie Ihre Internetverbindung.",
6363
"Cancel": "Abbrechen",
64+
"Checked": "Angehakt",
6465
"Close the modal": "Pop up schliessen",
6566
"Collaborate": "Zusammenarbeiten",
6667
"Collaborate and write in real time, without layout constraints.": "In Echtzeit und ohne Layout-Beschränkungen schreiben und zusammenarbeiten.",
@@ -247,6 +248,7 @@
247248
"Callout": "Destacado",
248249
"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.",
249250
"Cancel": "Cancelar",
251+
"Checked": "Marcado",
250252
"Close the modal": "Cerrar modal",
251253
"Collaborate": "Colabora",
252254
"Collaborate and write in real time, without layout constraints.": "Colaborar y escribir en tiempo real, sin restricciones de diseño.",
@@ -433,6 +435,7 @@
433435
"Callout": "Alerte",
434436
"Can't load this page, please check your internet connection.": "Impossible de charger cette page, veuillez vérifier votre connexion Internet.",
435437
"Cancel": "Annuler",
438+
"Checked": "Coché",
436439
"Close the modal": "Fermer la modale",
437440
"Collaborate": "Collaborer",
438441
"Collaborate and write in real time, without layout constraints.": "Collaborez et rédigez en temps réel, sans contrainte de mise en page.",
@@ -648,6 +651,7 @@
648651
"Beautify": "Filtro bellezza",
649652
"Can't load this page, please check your internet connection.": "Impossibile caricare questa pagina, controlla la tua connessione internet.",
650653
"Cancel": "Cancella",
654+
"Checked": "Selezionato",
651655
"Collaborate": "Collabora",
652656
"Collaborate and write in real time, without layout constraints.": "Collaborare e scrivere in tempo reale, senza vincoli di layout.",
653657
"Collaborative writing, Simplified.": "Scrittura collaborativa, semplificata.",
@@ -798,6 +802,7 @@
798802
"Beautify": "Maak mooier",
799803
"Can't load this page, please check your internet connection.": "Kan deze pagina niet laden. Controleer je internetverbinding.",
800804
"Cancel": "Breek af",
805+
"Checked": "Aangevinkt",
801806
"Close the modal": "Sluit het venster",
802807
"Collaborate": "Samenwerken",
803808
"Collaborate and write in real time, without layout constraints.": "Samenwerken en schrijven in realtime, zonder lay-out beperkingen.",
@@ -963,6 +968,7 @@
963968
"Anonymous": "Anonym",
964969
"Beautify": "Försköna",
965970
"Cancel": "Avbryt",
971+
"Checked": "Markerad",
966972
"Close the modal": "Stäng fönstret",
967973
"Convert Markdown": "Konvertera Markdown",
968974
"Correct": "Korrekt",
@@ -999,6 +1005,7 @@
9991005
"Banner image": "Afiş görseli",
10001006
"Beautify": "Güzelleştir",
10011007
"Cancel": "İptal",
1008+
"Checked": "İşaretli",
10021009
"Collaborate": "İşbirliği Yapın",
10031010
"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.",
10041011
"Collaborative writing, Simplified.": "İş birliğiyle yazmak çok daha Kolay.",
@@ -1086,6 +1093,7 @@
10861093
"Callout": "标注",
10871094
"Can't load this page, please check your internet connection.": "无法加载此页面,请检查您的网络连接。",
10881095
"Cancel": "取消",
1096+
"Checked": "已勾选",
10891097
"Close the modal": "关闭对话框",
10901098
"Collaborate": "协作",
10911099
"Collaborate and write in real time, without layout constraints.": "实时协作和写入,不受布局限制。",

0 commit comments

Comments
 (0)