Files
cinny/src/app/pages/client/sidebar/InboxTab.tsx
T
jaredandClaude Opus 5 e9d419f84c a11y: give every icon-only sidebar avatar button and the message sender avatar an accessible name (#185)
axe-core flagged 18 'button-name' criticals on the room view: the space
tabs, Home/Direct/Inbox/Search/Saved/Explore/Add Space/User Settings/
Unverified sidebar buttons, and each message's avatar button had no text
for screen readers. Labels mirror the existing tooltips; message avatars
read '<name>, open profile'. Room view now has zero button-name findings.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
2026-09-18 19:17:32 -04:00

69 lines
2.0 KiB
TypeScript

import React from 'react';
import { useNavigate } from 'react-router-dom';
import { Icon, Icons } from 'folds';
import { useAtomValue } from 'jotai';
import {
SidebarAvatar,
SidebarItem,
SidebarItemBadge,
SidebarItemTooltip,
} from '../../../components/sidebar';
import { allInvitesAtom } from '../../../state/room-list/inviteList';
import {
getInboxInvitesPath,
getInboxNotificationsPath,
getInboxPath,
joinPathComponent,
} from '../../pathUtils';
import { useInboxSelected } from '../../../hooks/router/useInbox';
import { UnreadBadge } from '../../../components/unread-badge';
import { ScreenSize, useScreenSizeContext } from '../../../hooks/useScreenSize';
import { useNavToActivePathAtom } from '../../../state/hooks/navToActivePath';
export function InboxTab() {
const screenSize = useScreenSizeContext();
const navigate = useNavigate();
const navToActivePath = useAtomValue(useNavToActivePathAtom());
const inboxSelected = useInboxSelected();
const allInvites = useAtomValue(allInvitesAtom);
const inviteCount = allInvites.length;
const handleInboxClick = () => {
if (screenSize === ScreenSize.Mobile) {
navigate(getInboxPath());
return;
}
const activePath = navToActivePath.get('inbox');
if (activePath) {
navigate(joinPathComponent(activePath));
return;
}
const path = inviteCount > 0 ? getInboxInvitesPath() : getInboxNotificationsPath();
navigate(path);
};
return (
<SidebarItem active={inboxSelected}>
<SidebarItemTooltip tooltip="Inbox">
{(triggerRef) => (
<SidebarAvatar
as="button"
ref={triggerRef}
aria-label="Inbox"
outlined
onClick={handleInboxClick}
>
<Icon src={Icons.Inbox} filled={inboxSelected} />
</SidebarAvatar>
)}
</SidebarItemTooltip>
{inviteCount > 0 && (
<SidebarItemBadge hasCount>
<UnreadBadge highlight count={inviteCount} />
</SidebarItemBadge>
)}
</SidebarItem>
);
}