Skip to content

Commit e0ef20b

Browse files
committed
✨(frontend) document visible in list are now openable via enter key
the document now appears in the list and can be opened using the enter key Signed-off-by: Cyril <[email protected]>
1 parent 62e122b commit e0ef20b

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ and this project adheres to
2424
- ♿(frontend) improve accessibility:
2525
- ♿(frontend) fix major accessibility issues reported by wave and axe #1344
2626
- #1341
27+
- #1349
28+
- #1271
29+
- #1341
30+
- #1365
2731
- ♻️(tilt) use helm dev-backend chart
2832

2933
### Removed

src/frontend/apps/impress/src/features/docs/docs-grid/components/DocsGridItem.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Tooltip, useModal } from '@openfun/cunningham-react';
22
import { DateTime } from 'luxon';
3+
import { useRouter } from 'next/router';
4+
import { KeyboardEvent } from 'react';
35
import { useTranslation } from 'react-i18next';
46
import { css } from 'styled-components';
57

@@ -23,6 +25,7 @@ export const DocsGridItem = ({ doc, dragMode = false }: DocsGridItemProps) => {
2325
const { t } = useTranslation();
2426
const { isDesktop } = useResponsiveStore();
2527
const { flexLeft, flexRight } = useResponsiveDocGrid();
28+
const router = useRouter();
2629
const { spacingsTokens } = useCunninghamTheme();
2730
const shareModal = useModal();
2831
const isPublic = doc.link_reach === LinkReach.PUBLIC;
@@ -33,6 +36,13 @@ export const DocsGridItem = ({ doc, dragMode = false }: DocsGridItemProps) => {
3336
shareModal.open();
3437
};
3538

39+
const handleKeyDown = (e: KeyboardEvent) => {
40+
if (e.key === 'Enter' || e.key === ' ') {
41+
e.preventDefault();
42+
void router.push(`/docs/${doc.id}`);
43+
}
44+
};
45+
3646
return (
3747
<>
3848
<Box
@@ -52,6 +62,10 @@ export const DocsGridItem = ({ doc, dragMode = false }: DocsGridItemProps) => {
5262
}
5363
`}
5464
className="--docs--doc-grid-item"
65+
onKeyDown={handleKeyDown}
66+
aria-label={t('Open document: {{title}}', {
67+
title: doc.title || t('Untitled document'),
68+
})}
5569
>
5670
<Box
5771
$flex={flexLeft}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@
371371
"Open Source": "Open Source",
372372
"Open the document options": "Öffnen Sie die Dokumentoptionen",
373373
"Open the header menu": "Öffne das Kopfzeilen-Menü",
374-
"Open document actions menu": "Dokumentaktionsmenü öffnen",
374+
"Open document: {{title}}": "Dokument öffnen: {{title}}",
375375
"Main content": "Hauptinhalt",
376376
"Home content": "Startseiten-Inhalt",
377377
"Documents grid": "Dokumentenraster",
@@ -478,6 +478,7 @@
478478
"Cancel the deletion": "Cancel the deletion",
479479
"Cancel the download": "Cancel the download",
480480
"Open actions menu for document: {{title}}": "Open actions menu for document: {{title}}",
481+
"Open document: {{title}}": "Open document: {{title}}",
481482
"Open the menu of actions for the document: {{title}}": "Open the menu of actions for the document: {{title}}",
482483
"Share with {{count}} users_one": "Share with {{count}} user",
483484
"Shared with {{count}} users_many": "Shared with {{count}} users",
@@ -606,7 +607,7 @@
606607
"Open Source": "Código abierto",
607608
"Open the document options": "Abrir las opciones del documento",
608609
"Open the header menu": "Abrir el menú de encabezado",
609-
"Open document actions menu": "Abrir menú de acciones del documento",
610+
"Open document: {{title}}": "Abrir documento: {{title}}",
610611
"Main content": "Contenido principal",
611612
"Home content": "Contenido de inicio",
612613
"Documents grid": "Lista de documentos",
@@ -838,7 +839,7 @@
838839
"Open Source": "Open Source",
839840
"Open the document options": "Ouvrir les options du document",
840841
"Open the header menu": "Ouvrir le menu d'en-tête",
841-
"Open document actions menu": "Ouvrir le menu d'actions du document",
842+
"Open document: {{title}}": "Ouvrir le document : {{title}}",
842843
"Open the menu of actions for the document: {{title}}": "Ouvrir le menu des actions du document : {{title}}",
843844
"Main content": "Contenu principal",
844845
"Home content": "Contenu d'accueil",
@@ -1203,7 +1204,7 @@
12031204
"Open Source": "Open Source",
12041205
"Open the document options": "Open document opties",
12051206
"Open the header menu": "Open het hoofdmenu",
1206-
"Open document actions menu": "Open documentactiemenu",
1207+
"Open document: {{title}}": "Document openen: {{title}}",
12071208
"Main content": "Hoofdinhoud",
12081209
"Home content": "Startpagina-inhoud",
12091210
"Documents grid": "Documentenraster",

0 commit comments

Comments
 (0)