Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ and this project adheres to

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

### Fixed

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

### Fixed

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

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,43 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => {

useUploadStatus(editor);

useEffect(() => {
if (!refEditorContainer.current) {
return;
}

const setEditorAriaAttributes = () => {
const editorElement =
refEditorContainer.current?.querySelector<HTMLElement>(
'.ProseMirror.bn-editor[contenteditable="true"]',
);

if (!editorElement) {
return;
}

const label = t('Document editor');

editorElement.setAttribute('aria-label', label);
editorElement.setAttribute('title', label);
};

setEditorAriaAttributes();

const observer = new MutationObserver(() => {
setEditorAriaAttributes();
});

observer.observe(refEditorContainer.current, {
childList: true,
subtree: true,
});

return () => {
observer.disconnect();
};
}, [t]);

Comment on lines +197 to +233
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it is overkill to add all this code to have a aria-label and title.
Adding a title will impact the readibility as well:

Image

useEffect(() => {
setEditor(editor);

Expand Down Expand Up @@ -226,7 +263,6 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => {
slashMenu={false}
theme="light"
comments={canSeeComment}
aria-label={t('Document editor')}
>
<BlockNoteSuggestionMenu />
<BlockNoteToolbar />
Expand All @@ -247,7 +283,6 @@ export const BlockNoteReader = ({
const { user } = useAuth();
const { setEditor } = useEditorStore();
const threadStore = useComments(docId, false, user);
const { t } = useTranslation();
const editor = useCreateBlockNote(
{
collaboration: {
Expand Down Expand Up @@ -289,7 +324,6 @@ export const BlockNoteReader = ({
editor={editor}
editable={false}
theme="light"
aria-label={t('Document viewer')}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will not have any aria-label here so.

formattingToolbar={false}
slashMenu={false}
comments={false}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { MouseEvent, useRef, useState } from 'react';
import { createPortal } from 'react-dom';
import { useTranslation } from 'react-i18next';

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

const iconRef = useRef<HTMLDivElement>(null);

Expand Down Expand Up @@ -83,6 +85,8 @@ export const DocIcon = ({
ref={iconRef}
onClick={toggleEmojiPicker}
color="tertiary-text"
aria-label={t(emoji ? 'Edit document emoji' : 'Add emoji')}
title={t(emoji ? 'Edit document emoji' : 'Add emoji')}
Comment on lines +88 to +89
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parser cannot extract the translation if the ternaire is inside the t

Suggested change
aria-label={t(emoji ? 'Edit document emoji' : 'Add emoji')}
title={t(emoji ? 'Edit document emoji' : 'Add emoji')}
aria-label={emoji ? t('Edit document emoji') : t('Add emoji')}
title={emoji ? t('Edit document emoji') : t('Add emoji')}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is cases where we cannot add emoji, so t('Add emoji') should not be everytime as a fallback, it depends if the user has the editing rights.

withEmojiPicker={doc.abilities.partial_update}

{...buttonProps}
>
{!emoji ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ export const DocShareModal = ({ doc, onClose, isRootDoc = true }: Props) => {
<ButtonCloseModal
aria-label={t('Close the share modal')}
onClick={onClose}
tabIndex={-1}
/>
</Box>
}
Expand Down
Loading
Loading