Skip to content

Commit 8a310d0

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 <[email protected]>
1 parent 9f9fae9 commit 8a310d0

File tree

16 files changed

+114
-39
lines changed

16 files changed

+114
-39
lines changed

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ and this project adheres to
88

99
## [Unreleased]
1010

11-
- ⚡️(frontend) improve accessibility:
12-
- #1341
13-
1411
### Added
1512

1613
- ✨(api) add API route to fetch document content #1206
14+
- ♿(frontend) improve accessibility:
15+
- #1349
16+
- #1271
17+
- #1341
1718

1819
### Changed
1920

@@ -41,7 +42,6 @@ and this project adheres to
4142
- ♿(frontend) improve accessibility for decorative images in editor #1282
4243
- #1338
4344
- #1281
44-
- #1271
4545
- ♻️(backend) fallback to email identifier when no name #1298
4646
- 🐛(backend) allow ASCII characters in user sub field #1295
4747
- ⚡️(frontend) improve fallback width calculation #1333

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,14 @@ test.describe('Doc Editor', () => {
463463
await expect(
464464
page.getByRole('button', {
465465
name: 'Download',
466+
exact: true,
466467
}),
467468
).toBeVisible();
468469

469470
void page
470471
.getByRole('button', {
471472
name: 'Download',
473+
exact: true,
472474
})
473475
.click();
474476

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ test.describe('Doc Export', () => {
3838
).toBeVisible();
3939
await expect(page.getByRole('combobox', { name: 'Format' })).toBeVisible();
4040
await expect(
41-
page.getByRole('button', { name: 'Close the modal' }),
41+
page.getByRole('button', {
42+
name: 'Close the download modal',
43+
}),
4244
).toBeVisible();
4345
await expect(page.getByTestId('doc-export-download-button')).toBeVisible();
4446
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ test.describe('Document grid item options', () => {
149149

150150
await page
151151
.getByRole('button', {
152-
name: 'Confirm deletion',
152+
name: 'Delete document',
153153
})
154154
.click();
155155

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ test.describe('Doc Header', () => {
100100

101101
await page
102102
.getByRole('button', {
103-
name: 'Confirm deletion',
103+
name: 'Delete document',
104104
})
105105
.click();
106106

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ test.describe('Document search', () => {
3333
).toBeVisible();
3434

3535
await expect(
36-
page.getByLabel('Search modal').getByText('search'),
36+
page.getByRole('heading', { name: 'Search docs' }),
3737
).toBeVisible();
3838

3939
const inputSearch = page.getByPlaceholder('Type the name of a document');
@@ -79,7 +79,7 @@ test.describe('Document search', () => {
7979

8080
await page.keyboard.press('Control+k');
8181
await expect(
82-
page.getByLabel('Search modal').getByText('search'),
82+
page.getByRole('heading', { name: 'Search docs' }),
8383
).toBeVisible();
8484

8585
await page.keyboard.press('Escape');

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,23 @@ 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+
$margin="0"
39+
id="alert-modal-title"
40+
$align="flex-start"
41+
$variation="1000"
42+
>
3543
{title}
3644
</Text>
3745
}
3846
rightActions={
3947
<>
4048
<Button
41-
aria-label={t('Close the modal')}
49+
aria-label={`${t('Cancel')} - ${title}`}
4250
color="secondary"
4351
fullWidth
4452
onClick={() => onClose()}
@@ -55,12 +63,11 @@ export const AlertModal = ({
5563
</>
5664
}
5765
>
58-
<Box
59-
aria-label={t('Confirmation button')}
60-
className="--docs--alert-modal"
61-
>
66+
<Box className="--docs--alert-modal">
6267
<Box>
63-
<Text $variation="600">{description}</Text>
68+
<Text $variation="600" as="p">
69+
{description}
70+
</Text>
6471
</Box>
6572
</Box>
6673
</Modal>

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

Lines changed: 5 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
>
@@ -31,6 +32,7 @@ export const ModalConfirmDownloadUnsafe = ({
3132
<Button
3233
aria-label={t('Download')}
3334
color="danger"
35+
data-testid="modal-download-unsafe-button"
3436
onClick={() => {
3537
if (onConfirm) {
3638
void onConfirm();
@@ -45,6 +47,8 @@ export const ModalConfirmDownloadUnsafe = ({
4547
size={ModalSize.SMALL}
4648
title={
4749
<Text
50+
as="h1"
51+
id="modal-confirm-download-unsafe-title"
4852
$gap="0.7rem"
4953
$size="h6"
5054
$align="flex-start"

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

Lines changed: 6 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,9 @@ export const ModalExport = ({ onClose, doc }: ModalExportProps) => {
165166
$width="100%"
166167
>
167168
<Text
169+
as="h1"
170+
$margin="0"
171+
id="modal-export-title"
168172
$size="h6"
169173
$variation="1000"
170174
$align="flex-start"
@@ -186,7 +190,7 @@ export const ModalExport = ({ onClose, doc }: ModalExportProps) => {
186190
$gap="1rem"
187191
className="--docs--modal-export-content"
188192
>
189-
<Text $variation="600" $size="sm">
193+
<Text $variation="600" $size="sm" as="p">
190194
{t('Download your document in a .docx or .pdf format.')}
191195
</Text>
192196
<Select

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

Lines changed: 8 additions & 9 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,8 +91,9 @@ export const ModalRemoveDoc = ({
9091
>
9192
<Text
9293
$size="h6"
93-
as="h6"
94-
$margin={{ all: '0' }}
94+
as="h1"
95+
id="modal-remove-doc-title"
96+
$margin="0"
9597
$align="flex-start"
9698
$variation="1000"
9799
>
@@ -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.

0 commit comments

Comments
 (0)