✨(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 <c.gromoff@gmail.com>
This commit is contained in:
@@ -17,6 +17,11 @@ and this project adheres to
|
|||||||
|
|
||||||
- 🐛(backend) duplicate sub docs as root for reader users
|
- 🐛(backend) duplicate sub docs as root for reader users
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- ♿(frontend) improve accessibility:
|
||||||
|
- ✨ add document visible in list and openable via enter key #1365
|
||||||
|
|
||||||
## [3.7.0] - 2025-09-12
|
## [3.7.0] - 2025-09-12
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Tooltip, useModal } from '@openfun/cunningham-react';
|
import { Tooltip, useModal } from '@openfun/cunningham-react';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
|
import { KeyboardEvent } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { css } from 'styled-components';
|
import { css } from 'styled-components';
|
||||||
|
|
||||||
@@ -33,6 +34,13 @@ export const DocsGridItem = ({ doc, dragMode = false }: DocsGridItemProps) => {
|
|||||||
shareModal.open();
|
shareModal.open();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleKeyDown = (e: KeyboardEvent) => {
|
||||||
|
if (e.key === 'Enter' || e.key === ' ') {
|
||||||
|
e.preventDefault();
|
||||||
|
(e.target as HTMLAnchorElement).click();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Box
|
<Box
|
||||||
@@ -52,6 +60,9 @@ export const DocsGridItem = ({ doc, dragMode = false }: DocsGridItemProps) => {
|
|||||||
}
|
}
|
||||||
`}
|
`}
|
||||||
className="--docs--doc-grid-item"
|
className="--docs--doc-grid-item"
|
||||||
|
aria-label={t('Open document: {{title}}', {
|
||||||
|
title: doc.title || t('Untitled document'),
|
||||||
|
})}
|
||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
$flex={flexLeft}
|
$flex={flexLeft}
|
||||||
@@ -68,6 +79,7 @@ export const DocsGridItem = ({ doc, dragMode = false }: DocsGridItemProps) => {
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
`}
|
`}
|
||||||
href={`/docs/${doc.id}`}
|
href={`/docs/${doc.id}`}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
data-testid={`docs-grid-name-${doc.id}`}
|
data-testid={`docs-grid-name-${doc.id}`}
|
||||||
|
|||||||
Reference in New Issue
Block a user