From 7b3f1da28ec33843b85315cb56d911913861dd6b Mon Sep 17 00:00:00 2001 From: Devesh Sawant Date: Thu, 6 Mar 2025 22:26:19 +0530 Subject: [PATCH] Added support for aria labels in IconButtons & aria roles in menus The dropdown menus on Mobile navbar had no roles,labels. Currently, the roles are updated as per ARIA guidelines (menu). The snapshot of MobileNav is also updated with the change in markup. Fixes the lack of description when accessibility readers are processing the button. --- client/common/IconButton.jsx | 9 ++-- .../IDE/components/Header/MobileNav.jsx | 51 +++++++++++++++---- .../__snapshots__/Nav.unit.test.jsx.snap | 14 +++++ 3 files changed, 62 insertions(+), 12 deletions(-) diff --git a/client/common/IconButton.jsx b/client/common/IconButton.jsx index 8cf732f91d..6d022fbd2f 100644 --- a/client/common/IconButton.jsx +++ b/client/common/IconButton.jsx @@ -13,7 +13,7 @@ const ButtonWrapper = styled(Button)` `; const IconButton = (props) => { - const { icon, ...otherProps } = props; + const { icon, ariaLabel, ...otherProps } = props; const Icon = icon; return ( @@ -22,17 +22,20 @@ const IconButton = (props) => { iconOnly display={Button.displays.inline} focusable="false" + aria-label={ariaLabel} {...otherProps} /> ); }; IconButton.propTypes = { - icon: PropTypes.func + icon: PropTypes.func, + ariaLabel: PropTypes.string }; IconButton.defaultProps = { - icon: null + icon: null, + ariaLabel: '' }; export default IconButton; diff --git a/client/modules/IDE/components/Header/MobileNav.jsx b/client/modules/IDE/components/Header/MobileNav.jsx index 349d3d1709..443a96d22e 100644 --- a/client/modules/IDE/components/Header/MobileNav.jsx +++ b/client/modules/IDE/components/Header/MobileNav.jsx @@ -249,7 +249,7 @@ const MobileNav = () => {
- +
@@ -262,7 +262,7 @@ const MobileNav = () => { ) : (
- +
)} @@ -271,7 +271,7 @@ const MobileNav = () => { ) : (
- +
)} @@ -291,8 +291,19 @@ const StuffMenu = () => { return (
- -
    + +