-
Notifications
You must be signed in to change notification settings - Fork 472
♿(frontend) add missing label and fix Axes errors to improve a11y #1693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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]); | ||
|
|
||
| useEffect(() => { | ||
| setEditor(editor); | ||
|
|
||
|
|
@@ -226,7 +263,6 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => { | |
| slashMenu={false} | ||
| theme="light" | ||
| comments={canSeeComment} | ||
| aria-label={t('Document editor')} | ||
| > | ||
| <BlockNoteSuggestionMenu /> | ||
| <BlockNoteToolbar /> | ||
|
|
@@ -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: { | ||
|
|
@@ -289,7 +324,6 @@ export const BlockNoteReader = ({ | |
| editor={editor} | ||
| editable={false} | ||
| theme="light" | ||
| aria-label={t('Document viewer')} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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} | ||
|
|
||
| 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/'; | ||||||||||||
|
|
@@ -30,6 +31,7 @@ export const DocIcon = ({ | |||||||||||
| ...textProps | ||||||||||||
| }: DocIconProps) => { | ||||||||||||
| const { updateDocEmoji } = useDocTitleUpdate(); | ||||||||||||
| const { t } = useTranslation(); | ||||||||||||
|
|
||||||||||||
| const iconRef = useRef<HTMLDivElement>(null); | ||||||||||||
|
|
||||||||||||
|
|
@@ -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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The parser cannot extract the translation if the ternaire is inside the
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is cases where we cannot add emoji, so docs/src/frontend/apps/impress/src/features/docs/doc-header/components/DocTitle.tsx Line 87 in 8036f16
|
||||||||||||
| {...buttonProps} | ||||||||||||
| > | ||||||||||||
| {!emoji ? ( | ||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
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: