fix: accessibility issue in side bar's footer (#3130)

* fix: accessibility issues in side bar footer icons

* small accessibility changes & formatting

* chore: fixed misspell

* chore: code cleanup

* added proper aria-labels and added with the footer as `ul`

* chore: code cleanup

---------

Co-authored-by: Shrilakshmi Shastry <shrilakshmi.shastry@smallcase.com>
This commit is contained in:
Pragadesh-45 2024-09-20 14:22:12 +05:30 committed by GitHub
parent 563683b5c1
commit b60c799645
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 101 additions and 46 deletions

View File

@ -93,10 +93,12 @@ const Notifications = () => {
dispatch(fetchNotifications()); dispatch(fetchNotifications());
setShowNotificationsModal(true); setShowNotificationsModal(true);
}} }}
aria-label="Check all Notifications"
> >
<ToolHint text="Notifications" toolhintId="Notifications" offset={8} > <ToolHint text="Notifications" toolhintId="Notifications" offset={8}>
<IconBell <IconBell
size={18} size={18}
aria-hidden
strokeWidth={1.5} strokeWidth={1.5}
className={`mr-2 ${unreadNotifications?.length > 0 ? 'bell' : ''}`} className={`mr-2 ${unreadNotifications?.length > 0 ? 'bell' : ''}`}
/> />
@ -133,8 +135,9 @@ const Notifications = () => {
{notifications?.slice(notificationsStartIndex, notificationsEndIndex)?.map((notification) => ( {notifications?.slice(notificationsStartIndex, notificationsEndIndex)?.map((notification) => (
<li <li
key={notification.id} key={notification.id}
className={`p-4 flex flex-col justify-center ${selectedNotification?.id == notification.id ? 'active' : notification.read ? 'read' : '' className={`p-4 flex flex-col justify-center ${
}`} selectedNotification?.id == notification.id ? 'active' : notification.read ? 'read' : ''
}`}
onClick={handleNotificationItemClick(notification)} onClick={handleNotificationItemClick(notification)}
> >
<div className="notification-title w-full">{notification?.title}</div> <div className="notification-title w-full">{notification?.title}</div>
@ -144,8 +147,9 @@ const Notifications = () => {
</ul> </ul>
<div className="w-full pagination flex flex-row gap-4 justify-center p-2 items-center text-xs"> <div className="w-full pagination flex flex-row gap-4 justify-center p-2 items-center text-xs">
<button <button
className={`pl-2 pr-2 py-3 select-none ${pageNumber <= 1 ? 'opacity-50' : 'text-link cursor-pointer hover:underline' className={`pl-2 pr-2 py-3 select-none ${
}`} pageNumber <= 1 ? 'opacity-50' : 'text-link cursor-pointer hover:underline'
}`}
onClick={handlePrev} onClick={handlePrev}
> >
{'Prev'} {'Prev'}
@ -161,8 +165,9 @@ const Notifications = () => {
</div> </div>
</div> </div>
<button <button
className={`pl-2 pr-2 py-3 select-none ${pageNumber == totalPages ? 'opacity-50' : 'text-link cursor-pointer hover:underline' className={`pl-2 pr-2 py-3 select-none ${
}`} pageNumber == totalPages ? 'opacity-50' : 'text-link cursor-pointer hover:underline'
}`}
onClick={handleNext} onClick={handleNext}
> >
{'Next'} {'Next'}

View File

@ -82,16 +82,12 @@ const TitleBar = () => {
) : null} ) : null}
<div className="flex items-center"> <div className="flex items-center">
<div className="flex items-center cursor-pointer" onClick={handleTitleClick}> <button className="flex items-center gap-2 text-sm font-medium" onClick={handleTitleClick}>
<Bruno width={30} /> <span aria-hidden>
</div> <Bruno width={30} />
<div </span>
onClick={handleTitleClick}
className="flex items-center font-medium select-none cursor-pointer"
style={{ fontSize: 14, paddingLeft: 6, position: 'relative', top: -1 }}
>
bruno bruno
</div> </button>
<div className="collection-dropdown flex flex-grow items-center justify-end"> <div className="collection-dropdown flex flex-grow items-center justify-end">
<Dropdown onCreate={onMenuDropdownCreate} icon={<MenuIcon />} placement="bottom-start"> <Dropdown onCreate={onMenuDropdownCreate} icon={<MenuIcon />} placement="bottom-start">
<div <div

View File

@ -20,7 +20,7 @@ const MAX_LEFT_SIDEBAR_WIDTH = 600;
const Sidebar = () => { const Sidebar = () => {
const leftSidebarWidth = useSelector((state) => state.app.leftSidebarWidth); const leftSidebarWidth = useSelector((state) => state.app.leftSidebarWidth);
const preferencesOpen = useSelector((state) => state.app.showPreferences); const preferencesOpen = useSelector((state) => state.app.showPreferences);
const [goldenEditonOpen, setGoldenEditonOpen] = useState(false); const [goldenEditionOpen, setGoldenEditionOpen] = useState(false);
const [asideWidth, setAsideWidth] = useState(leftSidebarWidth); const [asideWidth, setAsideWidth] = useState(leftSidebarWidth);
const [cookiesOpen, setCookiesOpen] = useState(false); const [cookiesOpen, setCookiesOpen] = useState(false);
@ -83,10 +83,43 @@ const Sidebar = () => {
return ( return (
<StyledWrapper className="flex relative h-screen"> <StyledWrapper className="flex relative h-screen">
<aside> <aside>
{goldenEditonOpen && <GoldenEdition onClose={() => setGoldenEditonOpen(false)} />} {goldenEditionOpen && (
<GoldenEdition
onClose={() => {
setGoldenEditionOpen(false);
document.querySelector('[data-trigger="golden-edition"]').focus();
}}
aria-modal="true"
role="dialog"
aria-labelledby="golden-edition-title"
aria-describedby="golden-edition-description"
/>
)}
<div className="flex flex-row h-screen w-full"> <div className="flex flex-row h-screen w-full">
{preferencesOpen && <Preferences onClose={() => dispatch(showPreferences(false))} />} {preferencesOpen && (
{cookiesOpen && <Cookies onClose={() => setCookiesOpen(false)} />} <Preferences
onClose={() => {
dispatch(showPreferences(false));
document.querySelector('[data-trigger="preferences"]').focus();
}}
aria-modal="true"
role="dialog"
aria-labelledby="preferences-title"
aria-describedby="preferences-description"
/>
)}
{cookiesOpen && (
<Cookies
onClose={() => {
setCookiesOpen(false);
document.querySelector('[data-trigger="cookies"]').focus();
}}
aria-modal="true"
role="dialog"
aria-labelledby="cookies-title"
aria-describedby="cookies-description"
/>
)}
<div className="flex flex-col w-full" style={{ width: asideWidth }}> <div className="flex flex-col w-full" style={{ width: asideWidth }}>
<div className="flex flex-col flex-grow"> <div className="flex flex-col flex-grow">
@ -96,30 +129,50 @@ const Sidebar = () => {
<div className="footer flex px-1 py-2 absolute bottom-0 left-0 right-0 items-center select-none"> <div className="footer flex px-1 py-2 absolute bottom-0 left-0 right-0 items-center select-none">
<div className="flex items-center ml-1 text-xs "> <div className="flex items-center ml-1 text-xs ">
<a className="mr-2 cursor-pointer" onClick={() => dispatch(showPreferences(true))}> <ul role="menubar" className="flex space-x-2">
<ToolHint text="Preferences" toolhintId="Preferences" effect='float' place='top-start' offset={8}> <li role="menuitem">
<IconSettings size={18} strokeWidth={1.5} /> <a
</ToolHint> className="cursor-pointer"
</a> data-trigger="preferences"
<a onClick={() => dispatch(showPreferences(true))}
className="mr-2 cursor-pointer" tabIndex={0}
onClick={() => setCookiesOpen(true)} aria-label="Open Preferences"
> >
<ToolHint text="Cookies" toolhintId="Cookies" offset={8}> <ToolHint text="Preferences" toolhintId="Preferences" effect="float" place="top-start" offset={8}>
<IconCookie size={18} strokeWidth={1.5} /> <IconSettings size={18} strokeWidth={1.5} aria-hidden="true" />
</ToolHint> </ToolHint>
</a> </a>
<a </li>
className="mr-2 cursor-pointer" <li role="menuitem">
onClick={() => setGoldenEditonOpen(true)} <a
> className="cursor-pointer"
<ToolHint text="Golden Edition" toolhintId="Golden Edition" offset={8} > data-trigger="cookies"
<IconHeart size={18} strokeWidth={1.5} /> onClick={() => setCookiesOpen(true)}
</ToolHint> tabIndex={0}
</a> aria-label="Open Cookies Settings"
<a> >
<Notifications /> <ToolHint text="Cookies" toolhintId="Cookies" offset={8}>
</a> <IconCookie size={18} strokeWidth={1.5} aria-hidden="true" />
</ToolHint>
</a>
</li>
<li role="menuitem">
<a
className="cursor-pointer"
data-trigger="golden-edition"
onClick={() => setGoldenEditionOpen(true)}
tabIndex={0}
aria-label="Open Golden Edition"
>
<ToolHint text="Golden Edition" toolhintId="Golden Edition" offset={8}>
<IconHeart size={18} strokeWidth={1.5} aria-hidden="true" />
</ToolHint>
</a>
</li>
<li role="menuitem">
<Notifications />
</li>
</ul>
</div> </div>
<div className="pl-1" style={{ position: 'relative', top: '3px' }}> <div className="pl-1" style={{ position: 'relative', top: '3px' }}>
{/* This will get moved to home page */} {/* This will get moved to home page */}
@ -129,7 +182,7 @@ const Sidebar = () => {
data-show-count="true" data-show-count="true"
aria-label="Star usebruno/bruno on GitHub" aria-label="Star usebruno/bruno on GitHub"
> >
Star Star
</GitHubButton> */} </GitHubButton> */}
</div> </div>
<div className="flex flex-grow items-center justify-end text-xs mr-2">v1.29.1</div> <div className="flex flex-grow items-center justify-end text-xs mr-2">v1.29.1</div>
@ -137,10 +190,11 @@ const Sidebar = () => {
</div> </div>
</div> </div>
</aside> </aside>
<div className="absolute drag-sidebar h-full" onMouseDown={handleDragbarMouseDown}> <div className="absolute drag-sidebar h-full" onMouseDown={handleDragbarMouseDown}>
<div className="drag-request-border" /> <div className="drag-request-border" />
</div> </div>
</StyledWrapper > </StyledWrapper>
); );
}; };