Skip to content

Commit 3463226

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 f5f9d8a commit 3463226

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

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: 31 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,6 +185,17 @@ 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 && (
@@ -179,6 +209,7 @@ export const DocTreeItemActions = ({
179209
});
180210
}}
181211
color="primary"
212+
aria-label={t('Add child document')}
182213
>
183214
<Icon
184215
variant="filled"

0 commit comments

Comments
 (0)