Skip to content

Conversation

@Ovgodd
Copy link
Collaborator

@Ovgodd Ovgodd commented Dec 2, 2025

Purpose

Improve keyboard accessibility for the document tree by implementing F2 navigation to access action buttons (three dots menu and add child button) for both root items and sub-pages.

issues : 1160

Enregistrement.de.l.ecran.2025-12-02.131853.mp4

Proposal

Keyboard Navigation

Key Context Action
Tab Document tree Navigate between documents (root → sub-pages)
F2 Focused document Move focus to first action button (three dots)
Enter Focused document Open the document
Enter Action button Activate button (open menu / create child)
Arrow Left/Right Action buttons Navigate between buttons
Escape Action buttons Return focus to document

Changes

  • Use ref to handle focus
  • Display actions when document is focused (like hover)
  • Hide document focus outline when focus is on actions

Accessibility

  • ✅ Actions are visible when document is focused (keyboard users see them)
  • ✅ Actions are not in tab order (reduces tab stops)
  • ✅ F2 is the standard key for accessing toolbars (ARIA best practices)
  • ✅ Arrow keys for navigation within toolbar (ARIA roving tabindex pattern)
  • ✅ Escape returns to main content (standard pattern)
  • ✅ Screen reader announces keyboard shortcuts (F2, arrows, Enter) when entering the tree

@Ovgodd Ovgodd requested a review from AntoLC December 2, 2025 12:22
@Ovgodd Ovgodd self-assigned this Dec 2, 2025
@Ovgodd Ovgodd changed the title Fix/a11y doctree options ♿️Improve keyboard accessibility for the document tree Dec 2, 2025
@Ovgodd Ovgodd force-pushed the fix/a11y-doctree-options branch from c49c1f7 to f72df6c Compare December 2, 2025 12:25
@github-actions
Copy link

github-actions bot commented Dec 2, 2025

Size Change: +687 B (+0.02%)

Total Size: 4.11 MB

Filename Size Change
apps/impress/out/_next/static/2f9e90ce/_buildManifest.js 0 B -906 B (removed) 🏆
apps/impress/out/_next/static/53b6db14/_buildManifest.js 905 B +905 B (new file) 🆕

compressed-size-action

@Ovgodd Ovgodd force-pushed the fix/a11y-doctree-options branch 2 times, most recently from 5f35f48 to 2914ea9 Compare December 2, 2025 12:39
@Ovgodd Ovgodd marked this pull request as ready for review December 2, 2025 13:23
@Ovgodd Ovgodd force-pushed the fix/a11y-doctree-options branch from 2480747 to 86d98f0 Compare December 2, 2025 13:30
opacity: 1;
}
}
/* Retirer le focus visuel du root item quand le focus est sur les actions */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* Retirer le focus visuel du root item quand le focus est sur les actions */
/* Remove visual focus from the root item when focus is on the actions */

display: flex;
}
}
/* Retirer le focus visuel du tree item quand le focus est sur les actions */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments should be in english.

@Ovgodd Ovgodd force-pushed the fix/a11y-doctree-options branch from 9504a1c to fa7d602 Compare December 3, 2025 09:48
@Ovgodd Ovgodd requested a review from AntoLC December 3, 2025 11:51
adds f2 shortcut to open options menu in sub-documents

Signed-off-by: Cyril <c.gromoff@gmail.com>
@Ovgodd Ovgodd force-pushed the fix/a11y-doctree-options branch 2 times, most recently from b177dfa to 7d22f33 Compare December 3, 2025 12:07
…treeview struct

Signed-off-by: Cyril <c.gromoff@gmail.com>
improves screen reader support with contextual accessibility guidance

Signed-off-by: Cyril <c.gromoff@gmail.com>
@Ovgodd Ovgodd force-pushed the fix/a11y-doctree-options branch from 7d22f33 to cf8e1d5 Compare December 3, 2025 12:09
Copy link
Collaborator

@AntoLC AntoLC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the problem about the double f2, it is intercepted by treeitem.

Image

It positions the focus on the emojipicker ^^ If you do f2 then enter, the picker open.

I suppose it is not the best that :
https://github.com/suitenumerique/ui-kit/blob/0b6f80100a85641c8227b4a61720722ec12691e2/src/components/tree-view/TreeView.tsx#L351-L359
From here: suitenumerique/ui-kit@c40f7f6

We need a way to pass props easily to this part, if we can have the hand on props.attr we should be able to add our own onKeyDown, but for that we need to move this line (l378 {...props.attrs}) to the line under onKeyDown (l390).(https://github.com/suitenumerique/ui-kit/blob/0b6f80100a85641c8227b4a61720722ec12691e2/src/components/tree-view/TreeView.tsx#L378-L379).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be removed as well.

const handleRootKeyDown = useCallback(
(e: React.KeyboardEvent) => {
// F2: focus first action button
if (e.key === 'F2' && !rootActionsOpen) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we assert that in a e2e test ?

}
`}
>
{/* Instructions clavier pour les lecteurs d'écran */}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English

Comment on lines +199 to +213
$css={css`
background: transparent;
border: none;
padding: 0;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
&:focus-visible {
outline: 2px solid var(--c--globals--colors--brand-500) !important;
outline-offset: -2px;
border-radius: var(--c--globals--spacings--st);
}
`}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BoxButton has already all that:

$css={css`
cursor: ${props.disabled ? 'not-allowed' : 'pointer'};
border: none;
outline: none;
font-family: inherit;
color: ${props.disabled &&
`var(--c--contextuals--content--semantic--disabled--primary)`};
&:focus-visible {
transition: none;
outline: 2px solid
var(--c--contextuals--content--semantic--${theme}--${variation});
border-radius: 1px;
outline-offset: var(--c--globals--spacings--st);
}
${$css || ''}
`}

aria-label={t('Add a sub page')}
data-testid="doc-tree-item-actions-add-child"
tabIndex={-1}
$css={css`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same BoxButton has already that, you just need to set the correct theme and variation props:

&:focus-visible {
transition: none;
outline: 2px solid
var(--c--contextuals--content--semantic--${theme}--${variation});
border-radius: 1px;
outline-offset: var(--c--globals--spacings--st);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants