From e14622ff663f3b117f9fd7678227a3012acd786a Mon Sep 17 00:00:00 2001 From: Your name Date: Thu, 6 Feb 2025 14:47:04 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BF=EF=B8=8F=20(frontend)=20modal=20optio?= =?UTF-8?q?ns=20modified?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The modal for document options has been modified to allow navigation using "tab" and to be closed. --- .../impress/src/components/DropButton.tsx | 49 ++++++++++++++----- .../src/cunningham/cunningham-style.css | 1 + 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/frontend/apps/impress/src/components/DropButton.tsx b/src/frontend/apps/impress/src/components/DropButton.tsx index 92aaca69..826b58ca 100644 --- a/src/frontend/apps/impress/src/components/DropButton.tsx +++ b/src/frontend/apps/impress/src/components/DropButton.tsx @@ -1,3 +1,4 @@ +import { FocusScope } from '@react-aria/focus'; import { PropsWithChildren, ReactNode, @@ -6,6 +7,7 @@ import { useState, } from 'react'; import { Button, Popover } from 'react-aria-components'; +import { useTranslation } from 'react-i18next'; import styled from 'styled-components'; const StyledPopover = styled(Popover)` @@ -14,6 +16,7 @@ const StyledPopover = styled(Popover)` box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1); border: 1px solid #dddddd; transition: opacity 0.2s ease-in-out; + padding: 1rem; `; const StyledButton = styled(Button)` @@ -27,6 +30,10 @@ const StyledButton = styled(Button)` font-size: 0.938rem; padding: 0; text-wrap: nowrap; + + &:focus-within { + outline: 2px solid #007bff; + } `; export interface DropButtonProps { @@ -42,12 +49,16 @@ export const DropButton = ({ onOpenChange, children, }: PropsWithChildren) => { + const { t } = useTranslation(); const [isLocalOpen, setIsLocalOpen] = useState(isOpen); - const triggerRef = useRef(null); + const triggerRef = useRef(null); + const firstFocusableRef = useRef(null); useEffect(() => { - setIsLocalOpen(isOpen); - }, [isOpen]); + if (isLocalOpen && firstFocusableRef.current) { + firstFocusableRef.current.focus(); + } + }, [isLocalOpen]); const onOpenChangeHandler = (isOpen: boolean) => { setIsLocalOpen(isOpen); @@ -56,17 +67,33 @@ export const DropButton = ({ return ( <> - onOpenChangeHandler(true)}> + onOpenChangeHandler(true)} + aria-haspopup="true" + aria-expanded={isLocalOpen} + aria-label={t('Open the document options')} + > - - {children} - + {isLocalOpen && ( + + + {children} + + + + )} ); }; diff --git a/src/frontend/apps/impress/src/cunningham/cunningham-style.css b/src/frontend/apps/impress/src/cunningham/cunningham-style.css index f617eb33..bad5a61c 100644 --- a/src/frontend/apps/impress/src/cunningham/cunningham-style.css +++ b/src/frontend/apps/impress/src/cunningham/cunningham-style.css @@ -203,6 +203,7 @@ input:-webkit-autofill:focus { .c__select__wrapper .c__select__inner__actions__open:focus { outline: none; + } .c__select__wrapper .labelled-box__label.c__offscreen {