From ed6b67faeddbb24be6ae3e5f0ff1f590397ab664 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Mon, 23 Nov 2026 09:15:28 +0800 Subject: [PATCH] fix(run): keep configuration types reachable in short windows (#5277) Add New Configuration keeps the title and search field above a scrollable list. The picker keeps its width while filtering with the standard 16 px icons and shows more types when the window has room. After filtering, Enter opens the configuration type highlighted in the list, including types under a group heading. --- e2e/runConfigLayout.spec.ts | 26 +++++++++++++++++++ src/features/run/AddConfigPopup.tsx | 39 ++++++++++++++++++----------- src/features/run/Run.module.css | 11 ++++++++ 3 files changed, 62 insertions(+), 14 deletions(-) diff --git a/e2e/runConfigLayout.spec.ts b/e2e/runConfigLayout.spec.ts index 6454c927d..265ff4ddc 100644 --- a/e2e/runConfigLayout.spec.ts +++ b/e2e/runConfigLayout.spec.ts @@ -98,6 +98,32 @@ test("long run target names leave room for configuration names in the sidebar", await expect(dialog.getByRole("textbox", { name: "Name", exact: true })).toHaveValue("Payments development server"); }); +test("the configuration type list scrolls below its search field in a short window", async ({ workbench: page }) => { + await page.setViewportSize({ width: 780, height: 370 }); + await openConfigurations(page); + const dialog = page.getByRole("dialog", { name: "Run/Debug Configurations", exact: true }); + await dialog.getByRole("button", { name: "Add New Configuration", exact: true }).click(); + const chooser = page.getByRole("dialog", { name: "Add New Configuration", exact: true }); + const search = chooser.getByRole("textbox", { name: "Search configuration types" }); + const list = chooser.getByRole("listbox", { name: "Configuration types" }); + await expect(search).toBeFocused(); + expect(await chooser.evaluate((el) => el.scrollHeight - el.clientHeight)).toBeLessThanOrEqual(1); + expect(await list.evaluate((el) => el.scrollHeight - el.clientHeight)).toBeGreaterThan(0); + + await search.press("End"); + const active = list.getByRole("option", { selected: true }); + await expect(active).toBeInViewport({ ratio: 0.98 }); + expect(await list.evaluate((el) => el.scrollTop)).toBeGreaterThan(0); + await expect(active.locator("svg")).toHaveAttribute("width", "16"); + await expect(search).toBeInViewport({ ratio: 1 }); + + await search.fill("Tomcat"); + await expect(list.getByRole("option", { name: "Tomcat Server", selected: true })).toBeVisible(); + await search.press("Enter"); + await expect(chooser).toBeHidden(); + await expect(dialog.getByRole("tab", { name: "Server", exact: true })).toBeVisible(); +}); + test("run configuration sidebar resizes with mouse and keyboard and remembers the layout", async ({ workbench: page, }) => { diff --git a/src/features/run/AddConfigPopup.tsx b/src/features/run/AddConfigPopup.tsx index 6eed4fd1d..fcc2b400b 100644 --- a/src/features/run/AddConfigPopup.tsx +++ b/src/features/run/AddConfigPopup.tsx @@ -1,6 +1,17 @@ -import { useMemo, useState, type KeyboardEvent } from "react"; +import { useMemo, useRef, useState, type KeyboardEvent } from "react"; import clsx from "clsx"; -import { HighlightedText, Icon, List, Popup, SearchField, fuzzyMatch, listNavigate, T, type PopupAnchor } from "@/ui"; +import { + HighlightedText, + Icon, + List, + Popup, + SearchField, + firstSelectable, + fuzzyMatch, + listNavigate, + T, + type PopupAnchor, +} from "@/ui"; import { useRowHeight } from "@/ui/density"; import { useRunConfigTypes, runConfigTypes, type RunConfigTypeContribution } from "@/workbench/contributions"; import styles from "./Run.module.css"; @@ -64,12 +75,11 @@ export function AddConfigPopup({ const [query, setQuery] = useState(""); const rows = useMemo(() => typeRows(runConfigTypes(types), query), [types, query]); const isSection = (r: TypeRow) => r.kind === "group"; - const first = Math.max( - 0, - rows.findIndex((r) => r.kind === "type"), - ); - const [active, setActive] = useState(first); + const [active, setActive] = useState(-1); const clamped = Math.min(active, rows.length - 1); + const selected = rows[clamped]?.kind === "type" ? clamped : firstSelectable(rows, isSection); + const viewport = useRef(null); + const height = Math.max(1, Math.min(rows.length, 30)) * rowHeight; const pick = (row: TypeRow | undefined) => { if (row?.kind !== "type") return; @@ -80,10 +90,11 @@ export function AddConfigPopup({ const onKeyDown = (e: KeyboardEvent) => { if (e.key === "Enter") { e.preventDefault(); - pick(rows[clamped]); + pick(rows[selected]); return; } - const next = listNavigate(e.key, { items: rows, active: clamped, isSection, wrap: true }); + const pageSize = Math.max(1, Math.floor((viewport.current?.clientHeight ?? height) / rowHeight) - 1); + const next = listNavigate(e.key, { items: rows, active: selected, isSection, pageSize, wrap: true }); if (next !== null) { e.preventDefault(); setActive(next); @@ -97,7 +108,7 @@ export function AddConfigPopup({ onClose={onClose} placement="bottom-start" aria-label="Add New Configuration" - className={styles.chooser} + className={clsx(styles.chooser, styles.typeChooser)} trapFocus >
@@ -108,7 +119,7 @@ export function AddConfigPopup({ value={query} onChange={(v) => { setQuery(v); - setActive(0); + setActive(-1); }} placeholder="Search types" aria-label="Search configuration types" @@ -117,7 +128,7 @@ export function AddConfigPopup({ variant="bare" />
-
+
aria-label="Configuration types" className={styles.chooserList} @@ -125,7 +136,7 @@ export function AddConfigPopup({ getKey={(r) => r.key} isSection={isSection} renderSection={(r) => (r.kind === "group" ? r.label : null)} - activeIndex={rows[clamped]?.kind === "type" ? clamped : first} + activeIndex={selected} onActiveChange={setActive} focusable={false} hoverSelects @@ -139,7 +150,7 @@ export function AddConfigPopup({ renderItem={(r) => r.kind === "type" ? ( - + {r.indices?.length ? : r.type.label} diff --git a/src/features/run/Run.module.css b/src/features/run/Run.module.css index 0f57b58cb..f01856028 100644 --- a/src/features/run/Run.module.css +++ b/src/features/run/Run.module.css @@ -560,6 +560,17 @@ color: var(--fg-secondary); font-weight: 500; } +.typeChooser { + width: 280px; +} +.typeChooser .chooserCaption { + padding: var(--space-2) var(--space-3) 0; + color: var(--fg-strong); + font-weight: 600; +} +.typeChooser .chooserSearch { + padding: var(--space-1) var(--space-3); +} .chooserMnemonic { flex: none; width: 8px;