From 646c74f2602b7008cbde5d5c3c4c8331ea3e56eb Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 6 Jul 2026 22:57:35 +0200 Subject: [PATCH] fix: Various unlabeled and undescribed interactive elements (#12912) * fix: Various unlabelled and undescribed interactable elements * fix: guard sort keydown against key repeat and label remaining help button Prevent held Space from repeatedly toggling table sort, and add an accessible name to the "Email subscriptions" help button. Co-Authored-By: Claude Opus 4.8 --------- Co-authored-by: Claude Opus 4.8 --- app/components/CircularProgressBar.tsx | 20 ++++- app/components/DocumentTasks.tsx | 2 +- .../IconPicker/components/EmojiPanel.tsx | 5 +- app/components/Modal.tsx | 2 +- .../components/ShareSettingsPopover.tsx | 8 +- app/components/Table.tsx | 77 ++++++++++++++----- shared/i18n/locales/en_US/translation.json | 1 + 7 files changed, 86 insertions(+), 29 deletions(-) diff --git a/app/components/CircularProgressBar.tsx b/app/components/CircularProgressBar.tsx index 5d0167a0e5..9fc5aeb32a 100644 --- a/app/components/CircularProgressBar.tsx +++ b/app/components/CircularProgressBar.tsx @@ -43,19 +43,37 @@ const Circle = ({ ); }; +/** + * Renders a small circular progress indicator. + * + * @param percentage - the progress to display, clamped to the range 0–100. + * @param size - the width and height of the indicator in pixels. + * @param label - an accessible name announced by assistive technology. + * @returns the rendered progress bar element. + */ const CircularProgressBar = ({ percentage, size = 16, + label, }: { percentage: number; size?: number; + label?: string; }) => { const theme = useTheme(); percentage = cleanPercentage(percentage); const offset = Math.floor(size / 2); return ( - + {percentage > 0 && ( diff --git a/app/components/DocumentTasks.tsx b/app/components/DocumentTasks.tsx index e5dd8688ad..c489e40e57 100644 --- a/app/components/DocumentTasks.tsx +++ b/app/components/DocumentTasks.tsx @@ -50,7 +50,7 @@ function DocumentTasks({ document }: Props) { $animated={done && previousDone === false} /> ) : ( - + )} {message} diff --git a/app/components/IconPicker/components/EmojiPanel.tsx b/app/components/IconPicker/components/EmojiPanel.tsx index 0f807589dc..494ae2e75c 100644 --- a/app/components/IconPicker/components/EmojiPanel.tsx +++ b/app/components/IconPicker/components/EmojiPanel.tsx @@ -184,7 +184,10 @@ const EmojiPanel = ({ data={templateData} onIconSelect={handleEmojiSelection} empty={ - + } diff --git a/app/components/Modal.tsx b/app/components/Modal.tsx index 01c2e98872..99a129dadc 100644 --- a/app/components/Modal.tsx +++ b/app/components/Modal.tsx @@ -103,7 +103,7 @@ const Modal: React.FC = ({ {resolvedTitle} - + diff --git a/app/components/Sharing/components/ShareSettingsPopover.tsx b/app/components/Sharing/components/ShareSettingsPopover.tsx index 964e797da1..14e62a08ad 100644 --- a/app/components/Sharing/components/ShareSettingsPopover.tsx +++ b/app/components/Sharing/components/ShareSettingsPopover.tsx @@ -295,7 +295,7 @@ function ShareSettingsPopover({ share, children }: Props) { "Display the last modified timestamp on the shared page" )} > - + @@ -320,7 +320,7 @@ function ShareSettingsPopover({ share, children }: Props) { "Display the table of contents on documents by default" )} > - + @@ -348,7 +348,7 @@ function ShareSettingsPopover({ share, children }: Props) { "Disable this setting to discourage search engines from indexing the page" )} > - + @@ -374,7 +374,7 @@ function ShareSettingsPopover({ share, children }: Props) { "Allow viewers to subscribe and receive email notifications when documents are updated" )} > - + diff --git a/app/components/Table.tsx b/app/components/Table.tsx index b4329f035a..bbaf81380c 100644 --- a/app/components/Table.tsx +++ b/app/components/Table.tsx @@ -176,28 +176,57 @@ function Table({ {table.getHeaderGroups().map((headerGroup) => (
- {headerGroup.headers.map((header) => ( - - { + const sorted = header.column.getIsSorted(); + const canSort = header.column.getCanSort(); + const toggleSorting = header.column.getToggleSortingHandler(); + const handleSortKeyDown = ( + ev: React.KeyboardEvent + ) => { + if (!ev.repeat && (ev.key === "Enter" || ev.key === " ")) { + ev.preventDefault(); + toggleSorting?.(ev); + } + }; + + return ( + - {flexRender( - header.column.columnDef.header, - header.getContext() - )} - {header.column.getIsSorted() === "asc" ? ( - - ) : header.column.getIsSorted() === "desc" ? ( - - ) : ( -
- )} - - - ))} + + {flexRender( + header.column.columnDef.header, + header.getContext() + )} + {sorted === "asc" ? ( + + ) : sorted === "desc" ? ( + + ) : ( +
+ )} + + + ); + })} ))} @@ -322,6 +351,11 @@ const SortWrapper = styled(Flex)<{ $sortable: boolean }>` background: ${(props) => props.$sortable ? props.theme.backgroundSecondary : "none"}; } + + &:focus-visible { + outline: 2px solid ${(props) => props.theme.accent}; + outline-offset: 2px; + } `; const InnerTable = styled.div` @@ -416,6 +450,7 @@ const TD = styled.span` background: ${s("sidebarControlHoverBackground")}; } + &:focus-visible, &[aria-expanded="true"] { opacity: 1; } diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index 949460e2fd..1ade8b3c25 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -468,6 +468,7 @@ "Site title": "Site title", "Show last modified": "Show last modified", "Display the last modified timestamp on the shared page": "Display the last modified timestamp on the shared page", + "More information": "More information", "Show table of contents": "Show table of contents", "Display the table of contents on documents by default": "Display the table of contents on documents by default", "Behavior": "Behavior",