Skip to content

Commit db056dd

Browse files
Luann Curiosootavio
authored andcommitted
fix(ui): announce sidebar logo once to screen readers
Both sidebar logos stay in the DOM and crossfade via CSS opacity, so screen readers announced the shared alt="ShellHub" twice. Mark whichever logo is visually hidden as aria-hidden so only the active one is exposed. Fixes: shellhub-io/team#135
1 parent 60002e2 commit db056dd

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

ui/apps/console/src/components/layout/SidebarShell.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,13 @@ export default function SidebarShell({
157157
<img
158158
src="/logo.svg"
159159
alt="ShellHub"
160+
aria-hidden={!expanded}
160161
className={`h-8 transition-opacity duration-200 ${expanded ? "opacity-100" : "opacity-0 absolute"}`}
161162
/>
162163
<img
163164
src="/cloud-icon.svg"
164165
alt="ShellHub"
166+
aria-hidden={expanded}
165167
className={`h-6 w-6 transition-opacity duration-200 ${expanded ? "opacity-0 absolute" : "opacity-100"}`}
166168
/>
167169
</NavLink>

ui/apps/console/src/components/layout/__tests__/SidebarShell.test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,18 @@ describe("SidebarShell", () => {
4646
const button = screen.getByRole("button", { name: "Close sidebar" });
4747
expect(button).toHaveAttribute("title", "Close sidebar");
4848
});
49+
50+
it("exposes only the expanded logo to assistive tech when expanded", () => {
51+
renderSidebarShell({ expanded: true });
52+
53+
// Both logos stay in the DOM (CSS opacity crossfade); aria-hidden keeps the
54+
// collapsed icon out of the accessibility tree so "ShellHub" is announced once.
55+
expect(screen.getAllByRole("img", { name: "ShellHub" })).toHaveLength(1);
56+
});
57+
58+
it("exposes only the collapsed logo to assistive tech when collapsed", () => {
59+
renderSidebarShell({ expanded: false });
60+
61+
expect(screen.getAllByRole("img", { name: "ShellHub" })).toHaveLength(1);
62+
});
4963
});

0 commit comments

Comments
 (0)