Skip to content

Commit f114216

Browse files
Olayinka AdelakunOlayinka Adelakun
authored andcommitted
fix(playground): correct sidebar-toggle label, fix inert aria-hidden props, and use shared axe helper in a11y tests
1 parent a9ba745 commit f114216

6 files changed

Lines changed: 33 additions & 20 deletions

File tree

src/frontend/src/components/core/appHeaderComponent/components/ThemeButtons/__tests__/ThemeButtons.a11y.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { render, screen } from "@testing-library/react";
2-
import { axe } from "jest-axe";
2+
import { axe } from "@/utils/a11y-test";
33
import { ThemeButtons } from "..";
44

55
describe("ThemeButtons accessibility", () => {

src/frontend/src/components/core/appHeaderComponent/components/ThemeButtons/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const ThemeButtons = () => {
6767
strokeWidth={2}
6868
name="Sun"
6969
className="w-4"
70-
aria-hidden="true"
70+
ariaHidden
7171
/>
7272
</Button>
7373

@@ -88,7 +88,7 @@ export const ThemeButtons = () => {
8888
strokeWidth={2}
8989
name="Moon"
9090
className="w-4"
91-
aria-hidden="true"
91+
ariaHidden
9292
/>
9393
</Button>
9494

@@ -109,7 +109,7 @@ export const ThemeButtons = () => {
109109
name="Monitor"
110110
className="w-4"
111111
strokeWidth={2}
112-
aria-hidden="true"
112+
ariaHidden
113113
/>
114114
</Button>
115115
</div>

src/frontend/src/components/ui/__tests__/textAnimation.a11y.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { render, screen } from "@testing-library/react";
2-
import { axe } from "jest-axe";
2+
import { axe } from "@/utils/a11y-test";
33
import { TextEffectPerChar } from "../textAnimation";
44

55
describe("TextEffectPerChar accessibility", () => {

src/frontend/src/modals/IOModal/__tests__/playground-modal.a11y.test.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { fireEvent, render, screen } from "@testing-library/react";
2-
import { axe } from "jest-axe";
32
import { TooltipProvider } from "@/components/ui/tooltip";
3+
import { axe } from "@/utils/a11y-test";
44
import IOModal from "../playground-modal";
55

66
// This suite only asserts the accessible-name fixes on IOModal's own icon
@@ -234,6 +234,19 @@ describe("IOModal (playground) accessibility", () => {
234234
expect(openVariantLogo).toHaveAttribute("aria-hidden", "true");
235235
});
236236

237+
it("flips the toggle's aria-label to 'Show sidebar' once collapsed", () => {
238+
renderPlayground();
239+
240+
fireEvent.click(screen.getByRole("button", { name: "Hide sidebar" }));
241+
242+
expect(
243+
screen.queryByRole("button", { name: "Hide sidebar" }),
244+
).not.toBeInTheDocument();
245+
expect(
246+
screen.getByRole("button", { name: "Show sidebar" }),
247+
).toBeInTheDocument();
248+
});
249+
237250
it("names the collapsed-sidebar 'Built with Langflow' button and hides its icon", () => {
238251
renderPlayground();
239252

src/frontend/src/modals/IOModal/components/IOFieldView/components/session-selector.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,23 +160,15 @@ export default function SessionSelector({
160160
aria-label={t("chat.cancelRename")}
161161
className="hover:text-status-red-hover ml-2 text-status-red"
162162
>
163-
<IconComponent
164-
name="X"
165-
className="h-4 w-4"
166-
aria-hidden="true"
167-
/>
163+
<IconComponent name="X" className="h-4 w-4" ariaHidden />
168164
</button>
169165
<button
170166
onClick={handleConfirm}
171167
data-confirm="true"
172168
aria-label={t("chat.confirmRename")}
173169
className="ml-2 text-accent-emerald-foreground hover:text-accent-emerald-foreground/80"
174170
>
175-
<IconComponent
176-
name="Check"
177-
className="h-4 w-4"
178-
aria-hidden="true"
179-
/>
171+
<IconComponent name="Check" className="h-4 w-4" ariaHidden />
180172
</button>
181173
</div>
182174
) : (
@@ -231,7 +223,7 @@ export default function SessionSelector({
231223
<IconComponent
232224
name="MoreHorizontal"
233225
className="h-4 w-4"
234-
aria-hidden="true"
226+
ariaHidden
235227
/>
236228
</SelectTrigger>
237229
</ShadTooltip>

src/frontend/src/modals/IOModal/playground-modal.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,18 +396,26 @@ export default function IOModal({
396396
<ShadTooltip
397397
styleClasses="z-50"
398398
side="right"
399-
content={t("modal.io.hideSidebar")}
399+
content={
400+
sidebarOpen
401+
? t("modal.io.hideSidebar")
402+
: t("modal.io.showSidebar")
403+
}
400404
>
401405
<Button
402406
variant="ghost"
403407
className="flex h-8 w-8 items-center justify-center !p-0"
404408
onClick={() => setSidebarOpen(!sidebarOpen)}
405-
aria-label={t("modal.io.hideSidebar")}
409+
aria-label={
410+
sidebarOpen
411+
? t("modal.io.hideSidebar")
412+
: t("modal.io.showSidebar")
413+
}
406414
>
407415
<IconComponent
408416
name={sidebarOpen ? "PanelLeftClose" : "PanelLeftOpen"}
409417
className="h-[18px] w-[18px] text-ring"
410-
aria-hidden="true"
418+
ariaHidden
411419
/>
412420
</Button>
413421
</ShadTooltip>

0 commit comments

Comments
 (0)