Skip to content

Commit 3b10b6e

Browse files
committed
✨(frontend) improve modal a11y: structure, labels, and title
added aria-label, structured text in p, and added title for better accessibility Signed-off-by: Cyril <c.gromoff@gmail.com>
1 parent 084d0c1 commit 3b10b6e

File tree

12 files changed

+88
-32
lines changed

12 files changed

+88
-32
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ and this project adheres to
2929
- ♿(frontend) improve accessibility for decorative images in editor #1282
3030
- #1338
3131
- #1281
32+
- #1349
3233
- ♻️(backend) fallback to email identifier when no name #1298
3334
- 🐛(backend) allow ASCII characters in user sub field #1295
3435
- ⚡️(frontend) improve fallback width calculation #1333

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ test.describe('Doc Export', () => {
3737
page.getByRole('combobox', { name: 'Template' }),
3838
).toBeVisible();
3939
await expect(page.getByRole('combobox', { name: 'Format' })).toBeVisible();
40-
await expect(
41-
page.getByRole('button', { name: 'Close the modal' }),
42-
).toBeVisible();
40+
await expect(page.getByTestId('modal-cancel-button')).toBeVisible();
4341
await expect(page.getByTestId('modal-download-button')).toBeVisible();
4442
});
4543

src/frontend/apps/impress/src/components/modal/AlertModal.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,22 @@ export const AlertModal = ({
3030
isOpen={isOpen}
3131
size={ModalSize.MEDIUM}
3232
onClose={onClose}
33+
aria-describedby="alert-modal-title"
3334
title={
34-
<Text $size="h6" $align="flex-start" $variation="1000">
35+
<Text
36+
$size="h6"
37+
as="h1"
38+
id="alert-modal-title"
39+
$align="flex-start"
40+
$variation="1000"
41+
>
3542
{title}
3643
</Text>
3744
}
3845
rightActions={
3946
<>
4047
<Button
41-
aria-label={t('Close the modal')}
48+
aria-label={`${t('Cancel')} - ${title}`}
4249
color="secondary"
4350
fullWidth
4451
onClick={() => onClose()}
@@ -55,12 +62,11 @@ export const AlertModal = ({
5562
</>
5663
}
5764
>
58-
<Box
59-
aria-label={t('Confirmation button')}
60-
className="--docs--alert-modal"
61-
>
65+
<Box className="--docs--alert-modal">
6266
<Box>
63-
<Text $variation="600">{description}</Text>
67+
<Text $variation="600" as="p">
68+
{description}
69+
</Text>
6470
</Box>
6571
</Box>
6672
</Modal>

src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteToolBar/ModalConfirmDownloadUnsafe.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ export const ModalConfirmDownloadUnsafe = ({
1919
isOpen
2020
closeOnClickOutside
2121
onClose={() => onClose()}
22+
aria-describedby="modal-confirm-download-unsafe-title"
2223
rightActions={
2324
<>
2425
<Button
25-
aria-label={t('Close the modal')}
26+
aria-label={t('Cancel the download')}
2627
color="secondary"
2728
onClick={() => onClose()}
2829
>
@@ -45,6 +46,8 @@ export const ModalConfirmDownloadUnsafe = ({
4546
size={ModalSize.SMALL}
4647
title={
4748
<Text
49+
as="h1"
50+
id="modal-confirm-download-unsafe-title"
4851
$gap="0.7rem"
4952
$size="h6"
5053
$align="flex-start"

src/frontend/apps/impress/src/features/docs/doc-export/components/ModalExport.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,11 @@ export const ModalExport = ({ onClose, doc }: ModalExportProps) => {
133133
closeOnClickOutside
134134
onClose={() => onClose()}
135135
hideCloseButton
136+
aria-describedby="modal-export-title"
136137
rightActions={
137138
<>
138139
<Button
139-
aria-label={t('Close the modal')}
140+
aria-label={t('Cancel the download')}
140141
color="secondary"
141142
fullWidth
142143
onClick={() => onClose()}
@@ -165,6 +166,8 @@ export const ModalExport = ({ onClose, doc }: ModalExportProps) => {
165166
$width="100%"
166167
>
167168
<Text
169+
as="h1"
170+
id="modal-export-title"
168171
$size="h6"
169172
$variation="1000"
170173
$align="flex-start"
@@ -186,7 +189,7 @@ export const ModalExport = ({ onClose, doc }: ModalExportProps) => {
186189
$gap="1rem"
187190
className="--docs--modal-export-content"
188191
>
189-
<Text $variation="600" $size="sm">
192+
<Text $variation="600" $size="sm" as="p">
190193
{t('Download your document in a .docx or .pdf format.')}
191194
</Text>
192195
<Select

src/frontend/apps/impress/src/features/docs/doc-management/components/ModalRemoveDoc.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,19 @@ export const ModalRemoveDoc = ({
5656
closeOnClickOutside
5757
hideCloseButton
5858
onClose={() => onClose()}
59+
aria-describedby="modal-remove-doc-title"
5960
rightActions={
6061
<>
6162
<Button
62-
aria-label={t('Close the delete modal')}
63+
aria-label={t('Cancel the deletion')}
6364
color="secondary"
6465
fullWidth
6566
onClick={() => onClose()}
6667
>
6768
{t('Cancel')}
6869
</Button>
6970
<Button
70-
aria-label={t('Confirm deletion')}
71+
aria-label={t('Delete document')}
7172
color="danger"
7273
fullWidth
7374
onClick={() =>
@@ -90,7 +91,8 @@ export const ModalRemoveDoc = ({
9091
>
9192
<Text
9293
$size="h6"
93-
as="h6"
94+
as="h1"
95+
id="modal-remove-doc-title"
9496
$margin={{ all: '0' }}
9597
$align="flex-start"
9698
$variation="1000"
@@ -104,12 +106,9 @@ export const ModalRemoveDoc = ({
104106
</Box>
105107
}
106108
>
107-
<Box
108-
aria-label={t('Content modal to delete document')}
109-
className="--docs--modal-remove-doc"
110-
>
109+
<Box className="--docs--modal-remove-doc">
111110
{!isError && (
112-
<Text $size="sm" $variation="600" $display="inline-block">
111+
<Text $size="sm" $variation="600" $display="inline-block" as="p">
113112
<Trans t={t}>
114113
This document and <strong>any sub-documents</strong> will be
115114
permanently deleted. This action is irreversible.

src/frontend/apps/impress/src/features/docs/doc-search/components/DocSearchModal.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useState } from 'react';
55
import { useTranslation } from 'react-i18next';
66
import { useDebouncedCallback } from 'use-debounce';
77

8-
import { Box } from '@/components';
8+
import { Box, Text } from '@/components';
99
import ButtonCloseModal from '@/components/modal/ButtonCloseModal';
1010
import { QuickSearch } from '@/components/quick-search';
1111
import { Doc, useDocUtils } from '@/docs/doc-management';
@@ -65,13 +65,17 @@ const DocSearchModalGlobal = ({
6565
closeOnClickOutside
6666
size={isDesktop ? ModalSize.LARGE : ModalSize.FULL}
6767
hideCloseButton
68+
aria-describedby="doc-search-modal-title"
6869
>
6970
<Box
7071
aria-label={t('Search modal')}
7172
$direction="column"
7273
$justify="space-between"
7374
className="--docs--doc-search-modal"
7475
>
76+
<Text as="h1" id="doc-search-modal-title" className="sr-only">
77+
{t('Search docs')}
78+
</Text>
7579
<Box $position="absolute" $css="top: 12px; right: 12px;">
7680
<ButtonCloseModal
7781
aria-label={t('Close the search modal')}

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,20 @@ export const DocShareModal = ({ doc, onClose, isRootDoc = true }: Props) => {
135135
isOpen
136136
closeOnClickOutside
137137
data-testid="doc-share-modal"
138-
aria-label={t('Share modal')}
138+
aria-describedby="doc-share-modal-title"
139139
size={isDesktop ? ModalSize.LARGE : ModalSize.FULL}
140140
onClose={onClose}
141141
title={
142142
<Box $direction="row" $justify="space-between" $align="center">
143-
<Box $align="flex-start">{t('Share the document')}</Box>
143+
<Text
144+
as="h1"
145+
id="doc-share-modal-title"
146+
$align="flex-start"
147+
$size="small"
148+
$weight="600"
149+
>
150+
{t('Share the document')}
151+
</Text>
144152
<ButtonCloseModal
145153
aria-label={t('Close the share modal')}
146154
onClick={onClose}
@@ -199,6 +207,7 @@ export const DocShareModal = ({ doc, onClose, isRootDoc = true }: Props) => {
199207
$textAlign="center"
200208
$variation="600"
201209
$size="sm"
210+
as="p"
202211
>
203212
{t(
204213
'You can view this document but need additional access to see its members or modify settings.',

src/frontend/apps/impress/src/features/docs/doc-versioning/components/ModalConfirmationVersion.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ export const ModalConfirmationVersion = ({
6969
isOpen
7070
closeOnClickOutside
7171
onClose={() => onClose()}
72+
aria-describedby="modal-confirmation-version-title"
7273
rightActions={
7374
<>
7475
<Button
75-
aria-label={t('Close the modal')}
76+
aria-label={`${t('Cancel')} - ${t('Warning')}`}
7677
color="secondary"
7778
fullWidth
7879
onClick={() => onClose()}
@@ -102,20 +103,23 @@ export const ModalConfirmationVersion = ({
102103
}
103104
size={ModalSize.SMALL}
104105
title={
105-
<Text $size="h6" $align="flex-start" $variation="1000">
106+
<Text
107+
as="h1"
108+
id="modal-confirmation-version-title"
109+
$size="h6"
110+
$align="flex-start"
111+
$variation="1000"
112+
>
106113
{t('Warning')}
107114
</Text>
108115
}
109116
>
110-
<Box
111-
aria-label={t('Modal confirmation to restore the version')}
112-
className="--docs--modal-confirmation-version"
113-
>
117+
<Box className="--docs--modal-confirmation-version">
114118
<Box>
115-
<Text $variation="600">
119+
<Text $variation="600" as="p">
116120
{t('Your current document will revert to this version.')}
117121
</Text>
118-
<Text $variation="600">
122+
<Text $variation="600" as="p">
119123
{t('If a member is editing, his works can be lost.')}
120124
</Text>
121125
</Box>

src/frontend/apps/impress/src/features/docs/doc-versioning/components/ModalSelectVersion.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export const ModalSelectVersion = ({
4848
closeOnClickOutside={true}
4949
size={ModalSize.EXTRA_LARGE}
5050
onClose={onClose}
51+
aria-describedby="modal-select-version-title"
5152
>
5253
<NoPaddingStyle />
5354
<Box
@@ -58,6 +59,9 @@ export const ModalSelectVersion = ({
5859
$maxHeight="calc(100vh - 2em - 12px)"
5960
$overflow="hidden"
6061
>
62+
<Text as="h1" id="modal-select-version-title" className="sr-only">
63+
{t('Version history')}
64+
</Text>
6165
<Box
6266
$css={css`
6367
display: flex;

0 commit comments

Comments
 (0)