Skip to content

Commit 3bd628a

Browse files
committed
fix(admin): replace locale toggle buttons with kumo Select
Toggle buttons don't scale beyond a few locales. Use the kumo Select dropdown instead. Add e2e tests for the language switcher.
1 parent 320c330 commit 3bd628a

File tree

2 files changed

+39
-17
lines changed

2 files changed

+39
-17
lines changed

e2e/tests/settings-pages.spec.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,37 @@ test.describe("SEO Settings", () => {
162162
});
163163
});
164164

165+
test.describe("Language Switcher", () => {
166+
test.beforeEach(async ({ admin }) => {
167+
await admin.devBypassAuth();
168+
});
169+
170+
test("settings page shows language select", async ({ admin, page }) => {
171+
await admin.goto("/settings");
172+
await admin.waitForShell();
173+
174+
const languageSelect = page.locator('[aria-label="Language"]');
175+
await expect(languageSelect).toBeVisible();
176+
});
177+
178+
test("switching language updates the UI", async ({ admin, page }) => {
179+
await admin.goto("/settings");
180+
await admin.waitForShell();
181+
182+
// Switch to German
183+
await page.locator('[aria-label="Language"]').click();
184+
await page.locator("[role='option']", { hasText: "Deutsch" }).click();
185+
186+
await expect(page.locator("h1")).toContainText("Einstellungen", { timeout: 5000 });
187+
188+
// Switch back — the select now shows "Deutsch" as its value
189+
await page.locator("[role='combobox']", { hasText: "Deutsch" }).click();
190+
await page.locator("[role='option']", { hasText: "English" }).click();
191+
192+
await expect(page.locator("h1")).toContainText("Settings", { timeout: 5000 });
193+
});
194+
});
195+
165196
test.describe("Email Settings", () => {
166197
test.beforeEach(async ({ admin }) => {
167198
await admin.devBypassAuth();

packages/admin/src/components/Settings.tsx

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Select } from "@cloudflare/kumo";
12
import { useLingui } from "@lingui/react/macro";
23
import {
34
Gear,
@@ -15,7 +16,6 @@ import { Link } from "@tanstack/react-router";
1516
import * as React from "react";
1617

1718
import { fetchManifest } from "../lib/api";
18-
import { cn } from "../lib/utils.js";
1919
import { SUPPORTED_LOCALES } from "../locales/index.js";
2020
import { useLocale } from "../locales/useLocale.js";
2121

@@ -130,22 +130,13 @@ export function Settings() {
130130
<div className="text-sm text-kumo-subtle">{t`Choose your preferred admin language`}</div>
131131
</div>
132132
</div>
133-
<div className="flex gap-1">
134-
{SUPPORTED_LOCALES.map((l) => (
135-
<button
136-
key={l.code}
137-
onClick={() => setLocale(l.code)}
138-
className={cn(
139-
"rounded-md px-3 py-1.5 text-sm transition-colors",
140-
l.code === locale
141-
? "bg-kumo-brand/10 text-kumo-brand font-medium"
142-
: "hover:bg-kumo-tint",
143-
)}
144-
>
145-
{l.label}
146-
</button>
147-
))}
148-
</div>
133+
<Select
134+
aria-label={t`Language`}
135+
className="w-45"
136+
value={locale}
137+
onValueChange={(v) => v && setLocale(v)}
138+
items={Object.fromEntries(SUPPORTED_LOCALES.map((l) => [l.code, l.label]))}
139+
/>
149140
</div>
150141
</div>
151142
)}

0 commit comments

Comments
 (0)