diff --git a/e2e/accessibility.spec.ts b/e2e/accessibility.spec.ts index b338009f..336e1a5c 100644 --- a/e2e/accessibility.spec.ts +++ b/e2e/accessibility.spec.ts @@ -56,7 +56,14 @@ for (const theme of THEMES) { await page.goto('/trino'); await waitForHydration(page); await page.getByRole('button', { name: 'Select run mode' }).click(); - await expect(page.getByRole('menu', { name: 'Select run mode' })).toBeVisible(); + const menu = page.getByRole('menu', { name: 'Select run mode' }); + await expect(menu).toBeVisible(); + // The dropdown fades in; mid-fade its text is blended with the background. + await menu.evaluate((el) => + Promise.all( + (el.closest('[popover]')?.getAnimations() ?? []).map((animation) => animation.finished) + ) + ); await expectNoViolations(page); }); diff --git a/e2e/i18n.spec.ts b/e2e/i18n.spec.ts index 8fdda957..04ff79d8 100644 --- a/e2e/i18n.spec.ts +++ b/e2e/i18n.spec.ts @@ -58,10 +58,10 @@ test.describe('Internationalisation', () => { await waitForHydration(page); await page.getByRole('button', { name: 'Language' }).click(); - const englishOption = page.locator('#lang-switcher button[lang="en"]'); - const deutschOption = page.locator('#lang-switcher button[lang="de"]'); - await expect(englishOption).toHaveAttribute('aria-current', 'true'); - await expect(deutschOption).not.toHaveAttribute('aria-current', 'true'); + const englishOption = page.getByRole('menuitemradio', { name: 'English' }); + const deutschOption = page.getByRole('menuitemradio', { name: 'Deutsch' }); + await expect(englishOption).toHaveAttribute('aria-checked', 'true'); + await expect(deutschOption).not.toHaveAttribute('aria-checked', 'true'); // setLocale triggers a page reload when changing locale. await deutschOption.click(); @@ -137,14 +137,14 @@ test.describe('Internationalisation', () => { await languageButton.click(); // Both language options visible with correct lang attributes - const englishOption = page.locator('#lang-switcher button[lang="en"]'); - const deutschOption = page.locator('#lang-switcher button[lang="de"]'); + const englishOption = page.getByRole('menuitemradio', { name: 'English' }); + const deutschOption = page.getByRole('menuitemradio', { name: 'Deutsch' }); await expect(englishOption).toBeVisible(); await expect(deutschOption).toBeVisible(); await expect(englishOption).toHaveAttribute('lang', 'en'); await expect(deutschOption).toHaveAttribute('lang', 'de'); - await expect(englishOption).toHaveAttribute('aria-current', 'true'); - await expect(deutschOption).not.toHaveAttribute('aria-current', 'true'); + await expect(englishOption).toHaveAttribute('aria-checked', 'true'); + await expect(deutschOption).not.toHaveAttribute('aria-checked', 'true'); }); }); diff --git a/e2e/storage/connections-management.spec.ts b/e2e/storage/connections-management.spec.ts index e05a9686..f7ce3631 100644 --- a/e2e/storage/connections-management.spec.ts +++ b/e2e/storage/connections-management.spec.ts @@ -196,6 +196,26 @@ test.describe('Storage — Connections management', () => { await expect(dataRows).toHaveCount(initialItems - 1); }); + test('connection menu opens next to its button from the keyboard', async ({ page }) => { + const credentials = requireGarageCredentials(); + await connectToStorage(page, credentials); + await page.goto('/settings/connections'); + await waitForHydration(page); + + const button = page.getByRole('button', { name: /Options for/i }).first(); + await button.focus(); + await button.press('Enter'); + + const menu = page.getByRole('menu', { name: /Options for/i }); + await expect(menu.getByRole('menuitem').first()).toBeFocused(); + // Right below the button and aligned to its right edge, not in the top-left corner. + const buttonBox = (await button.boundingBox())!; + const menuBox = (await menu.boundingBox())!; + expect(menuBox.y).toBeGreaterThanOrEqual(buttonBox.y + buttonBox.height); + expect(menuBox.y - (buttonBox.y + buttonBox.height)).toBeLessThan(24); + expect(Math.abs(menuBox.x + menuBox.width - (buttonBox.x + buttonBox.width))).toBeLessThan(24); + }); + test('sidebar on the edit page deletes a connection', async ({ page }) => { const credentials = requireGarageCredentials(); await connectToStorage(page, credentials); diff --git a/e2e/storage/context-menu.spec.ts b/e2e/storage/context-menu.spec.ts index 979e05d5..b6b7c250 100644 --- a/e2e/storage/context-menu.spec.ts +++ b/e2e/storage/context-menu.spec.ts @@ -99,7 +99,7 @@ test.describe('Storage S3 — Context Menu', () => { } }); - test('unpins a pinned location from its sidebar menu', async ({ page }, testInfo) => { + test('unpins a pinned location with its sidebar button', async ({ page }, testInfo) => { const credentials = requireGarageCredentials(); const client = createS3Client(credentials); const prefix = uniquePrefix(testInfo, 'ctx-unpin'); @@ -119,11 +119,12 @@ test.describe('Storage S3 — Context Menu', () => { const sidebar = page.getByRole('navigation', { name: 'Buckets' }); await expect(sidebar.getByText('Pinned Access')).toBeVisible(); - await sidebar.getByRole('button', { name: 'More options' }).click({ force: true }); - const menu = page.getByRole('menu', { name: 'Actions' }); - await menu.getByRole('menuitem', { name: 'Unpin' }).click(); + // The unpin button shows on hover and on keyboard focus. + const unpin = sidebar.getByRole('button', { name: `Unpin ${credentials.bucket}` }); + await unpin.focus(); + await expect(unpin).toBeVisible(); + await unpin.press('Enter'); - await expect(menu).toHaveCount(0); await expect(sidebar.getByText('Pinned Access')).toHaveCount(0); } finally { await deleteKnownKeys(client, credentials.bucket, cleanupKeys); diff --git a/messages/de.json b/messages/de.json index 33059d9f..6988c941 100644 --- a/messages/de.json +++ b/messages/de.json @@ -323,6 +323,7 @@ "storage_action_pin": "Ort anheften", "storage_action_details": "Details", "storage_action_unpin": "Loslösen", + "storage_unpin_location": "{name} loslösen", "storage_action_copy_filename": "Dateiname kopieren", "storage_action_copy_filename_success": "Dateiname in die Zwischenablage kopiert.", "storage_action_copy_filename_error": "Dateiname konnte nicht in die Zwischenablage kopiert werden.", diff --git a/messages/en.json b/messages/en.json index 647dbc5e..209154e8 100644 --- a/messages/en.json +++ b/messages/en.json @@ -323,6 +323,7 @@ "storage_action_pin": "Pin this location", "storage_action_details": "Details", "storage_action_unpin": "Unpin", + "storage_unpin_location": "Unpin {name}", "storage_action_copy_filename": "Copy filename", "storage_action_copy_filename_success": "Filename copied to clipboard.", "storage_action_copy_filename_error": "Could not copy filename to clipboard.", diff --git a/src/lib/components/DateTimePicker.svelte b/src/lib/components/DateTimePicker.svelte index a3b47531..e6efcbe6 100644 --- a/src/lib/components/DateTimePicker.svelte +++ b/src/lib/components/DateTimePicker.svelte @@ -9,7 +9,7 @@ positionPopoverRelativeToTrigger, supportsAnchorPositioning, trackPopover - } from '$lib/components/popover-position.js'; + } from '$lib/components/ui/popover-position.js'; import IconCalendar from 'virtual:icons/material-symbols/calendar-today'; import IconChevronLeft from 'virtual:icons/material-symbols/chevron-left'; import IconChevronRight from 'virtual:icons/material-symbols/chevron-right'; diff --git a/src/lib/components/layout/header/LanguageSwitcher.svelte b/src/lib/components/layout/header/LanguageSwitcher.svelte index 642881bb..a035d76c 100644 --- a/src/lib/components/layout/header/LanguageSwitcher.svelte +++ b/src/lib/components/layout/header/LanguageSwitcher.svelte @@ -3,6 +3,8 @@ import { getLocale, setLocale, locales } from '$lib/paraglide/runtime.js'; import IconLanguage from 'virtual:icons/material-symbols/language'; import IconCheck from 'virtual:icons/material-symbols/check'; + import Dropdown from '$lib/components/ui/Dropdown.svelte'; + import { handleMenuKeydown, menuItems } from '$lib/components/ui/menu-keyboard.js'; type LocaleMeta = { code: (typeof locales)[number]; @@ -21,54 +23,68 @@ availableLocales.find((locale) => locale.code === currentLocale) ?? availableLocales[0] ); + let open = $state(false); + function handleLocaleChange(locale: (typeof locales)[number]) { + open = false; void setLocale(locale); } + + /** Focuses the current language when the menu opens. */ + function focusCurrent(panel: HTMLElement) { + const items = menuItems(panel); + (items.find((item) => item.getAttribute('aria-checked') === 'true') ?? items[0])?.focus(); + } -