Skip to content

Commit b8fa5a5

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 9cb2b6a commit b8fa5a5

File tree

15 files changed

+98
-34
lines changed

15 files changed

+98
-34
lines changed

CHANGELOG.md

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

99
## [Unreleased]
1010

11-
### Added
11+
### Added
1212

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

1518
### Changed
1619

@@ -38,7 +41,6 @@ and this project adheres to
3841
- ♿(frontend) improve accessibility for decorative images in editor #1282
3942
- #1338
4043
- #1281
41-
- #1271
4244
- ♻️(backend) fallback to email identifier when no name #1298
4345
- 🐛(backend) allow ASCII characters in user sub field #1295
4446
- ⚡️(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/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: 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: 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')}

0 commit comments

Comments
 (0)