Skip to content

Commit b8a5e53

Browse files
committed
✨(frontend) add missing label to improve accessibility and pass axe checks
enhances a11y by adding label to fix axe tool errors on missing attributes Signed-off-by: Cyril <c.gromoff@gmail.com>
1 parent 8036f16 commit b8a5e53

File tree

5 files changed

+247
-204
lines changed

5 files changed

+247
-204
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ and this project adheres to
1010

1111
- ♿(frontend) improve accessibility:
1212
- ♿(frontend) add skip to content button for keyboard accessibility #1624
13+
- ♿(frontend) add missing label and fix Axes errors to improve a11y
14+
#1693
1315

1416
### Fixed
1517

@@ -22,8 +24,6 @@ and this project adheres to
2224
- ✨ Add comments feature to the editor #1330
2325
- ✨(backend) Comments on text editor #1330
2426
- ✨(frontend) link to create new doc #1574
25-
- ♿(frontend) improve accessibility:
26-
- ♿(frontend) add skip to content button for keyboard accessibility #1624
2727

2828
### Fixed
2929

@@ -52,6 +52,7 @@ and this project adheres to
5252
- ♻️(frontend) preserve @ character when esc is pressed after typing it #1512
5353
- ♻️(frontend) make summary button fixed to remain visible during scroll #1581
5454
- ♻️(frontend) pdf embed use full width #1526
55+
#1624
5556

5657
### Fixed
5758

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

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,43 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => {
194194

195195
useUploadStatus(editor);
196196

197+
useEffect(() => {
198+
if (!refEditorContainer.current) {
199+
return;
200+
}
201+
202+
const setEditorAriaAttributes = () => {
203+
const editorElement =
204+
refEditorContainer.current?.querySelector<HTMLElement>(
205+
'.ProseMirror.bn-editor[contenteditable="true"]',
206+
);
207+
208+
if (!editorElement) {
209+
return;
210+
}
211+
212+
const label = t('Document editor');
213+
214+
editorElement.setAttribute('aria-label', label);
215+
editorElement.setAttribute('title', label);
216+
};
217+
218+
setEditorAriaAttributes();
219+
220+
const observer = new MutationObserver(() => {
221+
setEditorAriaAttributes();
222+
});
223+
224+
observer.observe(refEditorContainer.current, {
225+
childList: true,
226+
subtree: true,
227+
});
228+
229+
return () => {
230+
observer.disconnect();
231+
};
232+
}, [t]);
233+
197234
useEffect(() => {
198235
setEditor(editor);
199236

@@ -226,7 +263,6 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => {
226263
slashMenu={false}
227264
theme="light"
228265
comments={canSeeComment}
229-
aria-label={t('Document editor')}
230266
>
231267
<BlockNoteSuggestionMenu />
232268
<BlockNoteToolbar />
@@ -247,7 +283,6 @@ export const BlockNoteReader = ({
247283
const { user } = useAuth();
248284
const { setEditor } = useEditorStore();
249285
const threadStore = useComments(docId, false, user);
250-
const { t } = useTranslation();
251286
const editor = useCreateBlockNote(
252287
{
253288
collaboration: {
@@ -289,7 +324,6 @@ export const BlockNoteReader = ({
289324
editor={editor}
290325
editable={false}
291326
theme="light"
292-
aria-label={t('Document viewer')}
293327
formattingToolbar={false}
294328
slashMenu={false}
295329
comments={false}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { MouseEvent, useRef, useState } from 'react';
22
import { createPortal } from 'react-dom';
3+
import { useTranslation } from 'react-i18next';
34

45
import { BoxButton, BoxButtonType, Text, TextType } from '@/components';
56
import { EmojiPicker, emojidata } from '@/docs/doc-editor/';
@@ -30,6 +31,7 @@ export const DocIcon = ({
3031
...textProps
3132
}: DocIconProps) => {
3233
const { updateDocEmoji } = useDocTitleUpdate();
34+
const { t } = useTranslation();
3335

3436
const iconRef = useRef<HTMLDivElement>(null);
3537

@@ -83,6 +85,8 @@ export const DocIcon = ({
8385
ref={iconRef}
8486
onClick={toggleEmojiPicker}
8587
color="tertiary-text"
88+
aria-label={t(emoji ? 'Edit document emoji' : 'Add emoji')}
89+
title={t(emoji ? 'Edit document emoji' : 'Add emoji')}
8690
{...buttonProps}
8791
>
8892
{!emoji ? (

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ export const DocShareModal = ({ doc, onClose, isRootDoc = true }: Props) => {
199199
<ButtonCloseModal
200200
aria-label={t('Close the share modal')}
201201
onClick={onClose}
202-
tabIndex={-1}
203202
/>
204203
</Box>
205204
}

0 commit comments

Comments
 (0)