fix(app): wrap arrow-key navigation in the theme list

This commit is contained in:
vaprdev
2026-11-05 00:35:59 +00:00
Unverified
parent f8b951cb38
commit 1ea7467e5f
3 changed files with 23 additions and 1 deletions
@@ -96,6 +96,21 @@ test("a settings page survives refresh", async ({ page }) => {
await expect(page).toHaveURL("/settings?tab=appearance")
})
test("arrow keys wrap around the theme list", async ({ page }) => {
const { settings } = await open(page)
await settings.getByRole("tab", { name: "Appearance", exact: true }).click()
await settings.locator('[data-action="settings-theme"]').click()
const options = page.getByRole("listbox").getByRole("option")
await expect(page.getByRole("option", { name: "OpenCode", selected: true })).toBeFocused()
await page.keyboard.press("End")
await expect(options.last()).toBeFocused()
await page.keyboard.press("ArrowDown")
await expect(options.first()).toBeFocused()
await page.keyboard.press("ArrowUp")
await expect(options.last()).toBeFocused()
})
test("Questions settings default independently of old Permissions settings and survive reload", async ({ page }) => {
const { settings } = await open(page, {
seed: {
@@ -125,6 +125,7 @@ export const SettingsAppearance: Component = () => {
current={appearance.theme.current()}
placement="bottom-end"
gutter={6}
shouldFocusWrap
value={(option) => option.id}
label={(option) => option.name}
onSelect={appearance.theme.select}
@@ -76,7 +76,13 @@ export function createAppearanceSettingsController() {
const platform = usePlatform()
const language = useLanguage()
const theme = useTheme()
const themes = createMemo(() => theme.ids().map((id) => ({ id, name: theme.name(id) })))
// Keep the same option objects while themes load, so an open theme list keeps keyboard focus.
const themes = createMemo(() => theme.ids().map((id) => ({ id, name: theme.name(id) })), undefined, {
equals: (prev, next) =>
prev.length === next.length &&
prev.every((option, index) => option.id === next[index].id && option.name === next[index].name),
})
onMount(() => void theme.loadThemes())