From e60621b979dd6471bbf2e0a56be05217b132b088 Mon Sep 17 00:00:00 2001 From: KitoC <35714838+KitoC@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:06:46 +1000 Subject: [PATCH] TPP-849 accessibility for floatin UI (#314) * fixed accessability issues * 3.2.20 --- lib/components/ActionsMenu/index.js | 51 +++++++------- lib/components/ActionsMenu/useActionMenu.js | 2 +- lib/components/Popover/index.js | 77 ++++++++++----------- package-lock.json | 4 +- package.json | 2 +- 5 files changed, 67 insertions(+), 69 deletions(-) diff --git a/lib/components/ActionsMenu/index.js b/lib/components/ActionsMenu/index.js index 7a7e182e..954a1ac0 100644 --- a/lib/components/ActionsMenu/index.js +++ b/lib/components/ActionsMenu/index.js @@ -66,8 +66,6 @@ const crossTransform2 = keyframes` const StyledActionsMenuContainer = styled.div` pointer-events: none; opacity: 0; - transition: all 300ms; - transition-timing-function: cubic-bezier(0, 1.4, 1, 1); &.visible { opacity: 1; @@ -186,12 +184,12 @@ export const ActionsMenuHeading = styled((props) => { `; export const ActionsMenuItem = styled((props) => { - const { id, onItemClick } = useContext(ActionMenuContext); + const { id, onItemClick, actionMenu } = useContext(ActionMenuContext); const { as, ...others } = props; const Component = as ? as : others.href ? "a" : "button"; - let newProps = others; + let newProps = { ...others, ...actionMenu.getItemProps() }; const { onClick: originalOnClick } = newProps; @@ -212,7 +210,7 @@ export const ActionsMenuItem = styled((props) => { } return ; -}).attrs({ role: "listitem" })` +}).attrs({ role: "menuitem" })` white-space: nowrap; display: block; width: 100%; @@ -330,27 +328,30 @@ export const ActionsMenuBody = ({ - - - - {children} - - - + + + {children} + + + + )} diff --git a/lib/components/ActionsMenu/useActionMenu.js b/lib/components/ActionsMenu/useActionMenu.js index 23a79d6b..49dde40e 100644 --- a/lib/components/ActionsMenu/useActionMenu.js +++ b/lib/components/ActionsMenu/useActionMenu.js @@ -54,7 +54,7 @@ export default function useActionMenu({ }); const dismiss = useDismiss(context); - const role = useRole(context); + const role = useRole(context, { role: "menu" }); const interactions = useInteractions([click, dismiss, role]); diff --git a/lib/components/Popover/index.js b/lib/components/Popover/index.js index a8c8c0bf..3c7b98eb 100644 --- a/lib/components/Popover/index.js +++ b/lib/components/Popover/index.js @@ -35,18 +35,6 @@ const DIRECTIONS_MAP = { bottomRight: "bottom-end" }; -const StyledPopoverContainer = styled.div` - pointer-events: none; - opacity: 0; - transition: all 300ms ease-in-out; - transition-delay: 300ms; - - &.visible { - opacity: 1; - pointer-events: auto; - } -`; - const TooltipControl = styled.div` border: none; background: none; @@ -81,7 +69,13 @@ const StyledPopover = styled.div` box-shadow: ${themeGet("shadows.boxDefault")}; user-select: ${(props) => (props.enableSelectAll ? "all" : "auto")}; - opacity: 1; + pointer-events: none; + opacity: 0; + + &.visible { + opacity: 1; + pointer-events: auto; + } & a { font-size: ${themeGet("fontSizes.0")}; @@ -289,7 +283,11 @@ export default function Popover({ ] }); - const hover = useHover(context, { move: false, handleClose: safePolygon() }); + const hover = useHover(context, { + move: false, + handleClose: safePolygon(), + delay: { open: 400, close: 0 } + }); const focus = useFocus(context); const dismiss = useDismiss(context); const role = useRole(context, { role: "tooltip" }); @@ -303,7 +301,8 @@ export default function Popover({ const triggerProps = { ...getReferenceProps({ - ref: refs.setReference + ref: refs.setReference, + "aria-describedby": context.floatingId }) }; @@ -338,33 +337,31 @@ export default function Popover({ root={getFloatingUiRootElement(context.refs.reference)} preserveTabOrder={true} > - {text && ( - - - - {text} - - - + {text} + + )} diff --git a/package-lock.json b/package-lock.json index d0705007..a916ee1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "orcs-design-system", - "version": "3.2.19", + "version": "3.2.20", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "orcs-design-system", - "version": "3.2.19", + "version": "3.2.20", "dependencies": { "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", diff --git a/package.json b/package.json index 4383f331..2743e8eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "orcs-design-system", - "version": "3.2.19", + "version": "3.2.20", "engines": { "node": "20.12.2" },