From 382c3c3228db66da6df540303c998e1dee41c9fa Mon Sep 17 00:00:00 2001 From: 0ko <0ko@noreply.codeberg.org> Date: Wed, 5 Nov 2025 05:00:15 +0100 Subject: [PATCH] feat(ui): allow dropdown to contain not just items (#9951) Currently the dropdown component only supports having one `` and one ` - +
+ +
diff --git a/templates/org/header.tmpl b/templates/org/header.tmpl index 8e796fb160..436d6eeb0c 100644 --- a/templates/org/header.tmpl +++ b/templates/org/header.tmpl @@ -22,21 +22,23 @@ {{svg "octicon-kebab-horizontal" 20}} - +
+ +
{{end}} diff --git a/templates/shared/user/actions_menu.tmpl b/templates/shared/user/actions_menu.tmpl index 0cc6b525ad..0ff85c0630 100644 --- a/templates/shared/user/actions_menu.tmpl +++ b/templates/shared/user/actions_menu.tmpl @@ -2,48 +2,53 @@ {{svg "octicon-kebab-horizontal"}} - + diff --git a/tests/e2e/dropdown.test.e2e.ts b/tests/e2e/dropdown.test.e2e.ts index cc73a20f4d..75e44ae1d8 100644 --- a/tests/e2e/dropdown.test.e2e.ts +++ b/tests/e2e/dropdown.test.e2e.ts @@ -2,7 +2,9 @@ // SPDX-License-Identifier: GPL-3.0-or-later // @watch start -// templates/shared/user/** +// templates/shared/user/actions_menu.tmpl +// templates/org/header.tmpl +// templates/explore/search.tmpl // web_src/js/modules/dropdown.ts // @watch end @@ -17,8 +19,8 @@ test('JS enhanced interaction', async ({page}) => { await expect(nojsNotice).toBeHidden(); // Open and close by clicking summary - const dropdownSummary = page.locator('details.dropdown summary'); - const dropdownContent = page.locator('details.dropdown ul'); + const dropdownSummary = page.locator('details.dropdown > summary'); + const dropdownContent = page.locator('details.dropdown > .content'); await expect(dropdownContent).toBeHidden(); await dropdownSummary.click(); await expect(dropdownContent).toBeVisible(); @@ -50,7 +52,7 @@ test('JS enhanced interaction', async ({page}) => { await dropdownSummary.press(`Escape`); await expect(dropdownContent).toBeHidden(); - // Open and close by opening a different dropdown + // Open and then close by opening a different dropdown const languageMenu = page.locator('.language-menu'); await dropdownSummary.click(); await expect(dropdownContent).toBeVisible(); @@ -70,8 +72,8 @@ test('No JS interaction', async ({browser}) => { await expect(nojsPage.locator('body')).toContainClass('no-js'); // Open and close by clicking summary - const dropdownSummary = nojsPage.locator('details.dropdown summary'); - const dropdownContent = nojsPage.locator('details.dropdown ul'); + const dropdownSummary = nojsPage.locator('details.dropdown > summary'); + const dropdownContent = nojsPage.locator('details.dropdown > .content'); await expect(dropdownContent).toBeHidden(); await dropdownSummary.click(); await expect(dropdownContent).toBeVisible(); @@ -113,7 +115,7 @@ test('Visual properties', async ({browser, isMobile}) => { await page.goto('/user1'); // Has `.border` and pretty small default `inline-padding:` - const summary = page.locator('details.dropdown summary'); + const summary = page.locator('details.dropdown > summary'); expect(await summary.evaluate((el) => getComputedStyle(el).border)).toBe('1px solid rgba(0, 0, 0, 0.114)'); expect(await summary.evaluate((el) => getComputedStyle(el).paddingInline)).toBe('7px'); @@ -139,8 +141,8 @@ test('Visual properties', async ({browser, isMobile}) => { } // Direction and item height - const content = page.locator('details.dropdown > ul'); - const itemsSel = 'details.dropdown > ul > li'; + const content = page.locator('details.dropdown > .content'); + const itemsSel = 'details.dropdown > .content > ul > li'; if (isMobile) { // `