Skip to content

Commit c94f0b2

Browse files
committed
⚡️(frontend) improve accessibility of selected document's sub-menu
adds focus-visible and focus-within to make the sub-menu accessible Signed-off-by: Cyril <[email protected]>
1 parent afbacb0 commit c94f0b2

File tree

7 files changed

+57
-4
lines changed

7 files changed

+57
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ and this project adheres to
1515
- #1235
1616
- #1255
1717
- #1262
18+
- #1261
19+
1820

1921
## [3.5.0] - 2025-07-31
2022

src/frontend/apps/e2e/__tests__/app-impress/utils-sub-pages.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,6 @@ export const clickOnAddRootSubPage = async (page: Page) => {
6363
const rootItem = page.getByTestId('doc-tree-root-item');
6464
await expect(rootItem).toBeVisible();
6565
await rootItem.hover();
66-
await rootItem.getByRole('button', { name: 'add_box' }).click();
66+
67+
await rootItem.getByTestId('add-child-doc').click();
6768
};

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,14 @@ export const SimpleDocItem = ({
5959
aria-hidden="true"
6060
aria-label={t('Pin document icon')}
6161
color={colorsTokens['primary-500']}
62+
aria-hidden="true"
6263
/>
6364
) : (
6465
<SimpleFileIcon
6566
aria-hidden="true"
6667
aria-label={t('Simple document icon')}
6768
color={colorsTokens['primary-500']}
69+
aria-hidden="true"
6870
/>
6971
)}
7072
</Box>

src/frontend/apps/impress/src/features/docs/doc-tree/components/DocSubPageItem.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,19 @@ export const DocSubPageItem = (props: TreeViewNodeProps<Doc>) => {
8787
: 'var(--c--theme--colors--greyscale-000)'};
8888
}
8989
90+
&:focus-within .light-doc-item-actions {
91+
display: flex;
92+
background: var(--c--theme--colors--greyscale-100);
93+
}
94+
9095
.c__tree-view--node.isSelected {
9196
.light-doc-item-actions {
9297
background: var(--c--theme--colors--greyscale-100);
9398
}
9499
}
95100
96-
&:hover {
101+
&:hover,
102+
&:focus-within {
97103
background-color: var(--c--theme--colors--greyscale-100);
98104
border-radius: 4px;
99105

src/frontend/apps/impress/src/features/docs/doc-tree/components/DocTree.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ export const DocTree = ({ currentDoc }: DocTreeProps) => {
189189
opacity: 1;
190190
}
191191
}
192-
&:hover {
192+
&:hover,
193+
&:focus-within {
193194
.doc-tree-root-item-actions {
194195
opacity: 1;
195196
}

src/frontend/apps/impress/src/features/docs/doc-tree/components/DocTreeItemActions.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,25 @@ export const DocTreeItemActions = ({
150150
$align="center"
151151
className="--docs--doc-tree-item-actions"
152152
$gap="4px"
153+
$css={css`
154+
&:focus-within {
155+
opacity: 1;
156+
visibility: visible;
157+
}
158+
button:focus-visible,
159+
[role='button']:focus-visible {
160+
outline: 2px solid var(--c--theme--colors--primary-500);
161+
outline-offset: 2px;
162+
background-color: var(--c--theme--colors--greyscale-050);
163+
border-radius: 4px;
164+
}
165+
.icon-button:focus-visible {
166+
outline: 2px solid var(--c--theme--colors--primary-500);
167+
outline-offset: 2px;
168+
background-color: var(--c--theme--colors--greyscale-050);
169+
border-radius: 4px;
170+
}
171+
`}
153172
>
154173
<DropdownMenu
155174
options={options}
@@ -166,10 +185,22 @@ export const DocTreeItemActions = ({
166185
variant="filled"
167186
$theme="primary"
168187
$variation="600"
188+
className="icon-button"
189+
tabIndex={0}
190+
role="button"
191+
aria-label={t('More options')}
192+
onKeyDown={(e) => {
193+
if (e.key === 'Enter' || e.key === ' ') {
194+
e.preventDefault();
195+
e.stopPropagation();
196+
onOpenChange?.(!isOpen);
197+
}
198+
}}
169199
/>
170200
</DropdownMenu>
171201
{doc.abilities.children_create && (
172202
<BoxButton
203+
data-testid="add-child-doc"
173204
onClick={(e) => {
174205
e.stopPropagation();
175206
e.preventDefault();
@@ -179,6 +210,7 @@ export const DocTreeItemActions = ({
179210
});
180211
}}
181212
color="primary"
213+
aria-label={t('Add child document')}
182214
>
183215
<Icon
184216
variant="filled"

src/frontend/apps/impress/src/i18n/translations.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@
270270
"Move": "Verschieben",
271271
"Move document": "Dokument verschieben",
272272
"Move to my docs": "In \"Meine Dokumente\" verschieben",
273+
"More options": "Weitere Optionen",
274+
"Add child document": "Unterdokument hinzufügen",
273275
"My docs": "Meine Dokumente",
274276
"Name": "Name",
275277
"New doc": "Neues Dokument",
@@ -377,7 +379,8 @@
377379
"Shared with {{count}} users_many": "Shared with {{count}} users",
378380
"Shared with {{count}} users_one": "Shared with {{count}} user",
379381
"Shared with {{count}} users_other": "Shared with {{count}} users",
380-
"Updated": "Updated"
382+
"Updated": "Updated",
383+
"Add child document": "Add child document"
381384
}
382385
},
383386
"es": {
@@ -560,6 +563,8 @@
560563
"You are the sole owner of this group, make another member the group owner before you can change your own role or be removed from your document.": "Eres el único propietario de este grupo, haz que otro miembro sea el propietario del grupo para poder cambiar tu propio rol o ser eliminado del documento.",
561564
"Your current document will revert to this version.": "Tu documento actual se revertirá a esta versión.",
562565
"Your {{format}} was downloaded succesfully": "Su {{format}} se ha descargado correctamente",
566+
"More options": "Más opciones",
567+
"Add child document": "Añadir documento hijo",
563568
"home-content-open-source-part1": "Docs está construido sobre <2>Django Rest Framework</2> y <6>Next.js</6>. También utilizamos <9>Yjs</9> y <13>BlockNote.js</13>, dos proyectos que estamos orgullosos de patrocinar.",
564569
"home-content-open-source-part2": "Puede autoalojar fácilmente Docs (consulte nuestra <2>documentación</2> de instalación).<br/>Docs utiliza una <7>licencia</7> (MIT) adecuada para la innovación y las empresas.<br/>Se aceptan contribuciones (consulte nuestra hoja de ruta <13>aquí</13>).",
565570
"home-content-open-source-part3": "Docs es el resultado de un esfuerzo conjunto llevado a cabo por los gobiernos francés 🇫🇷🥖 <1>(DINUM)</1> y alemán 🇩🇪🥨 <5>(ZenDiS)</5>."
@@ -694,6 +699,8 @@
694699
"Move": "Déplacer",
695700
"Move document": "Déplacer le document",
696701
"Move to my docs": "Déplacer vers mes docs",
702+
"More options": "Plus d'options",
703+
"Add child document": "Ajouter un document enfant",
697704
"My docs": "Mes documents",
698705
"Name": "Nom",
699706
"New doc": "Nouveau doc",
@@ -1122,6 +1129,8 @@
11221129
"You are the sole owner of this group, make another member the group owner before you can change your own role or be removed from your document.": "U bent de enige eigenaar van deze groep, maak een ander lid de groepseigenaar voordat u uw eigen rol kunt wijzigen of kan worden verwijderd van het document.",
11231130
"Your current document will revert to this version.": "Uw huidige document wordt teruggezet naar deze versie.",
11241131
"Your {{format}} was downloaded succesfully": "Jouw {{format}} is succesvol gedownload",
1132+
"More options": "Meer opties",
1133+
"Add child document": "Onderliggend document toevoegen",
11251134
"home-content-open-source-part1": "Docs is gebouwd op <2>Django Rest Framework</2> en <6>Next.js</6>. We gebruiken ook <9>Yjs</9> en <13>BlockNote.js</13>, twee projecten die we met trots sponsoren.",
11261135
"home-content-open-source-part2": "U kunt Docs eenvoudig zelf hosten (zie onze <2>installatiedocumentatie</2>).<br/>Docs gebruikt een <7>licentie</7> (MIT) die is afgestemd op innovatie en ondernemingen.<br/>Bijdragen zijn welkom (zie onze routekaart <13>hier</13>).",
11271136
"home-content-open-source-part3": "Docs is het resultaat van een gezamenlijke inspanning geleid door de Franse 🇫🇷🥖 <1>(DINUM)</1> en Duitse 🇩🇪🥨 <5>(ZenDiS)</5> overheden."

0 commit comments

Comments
 (0)