diff --git a/e2e/projectNewMenu.spec.ts b/e2e/projectNewMenu.spec.ts index e0eecd5c2..4d5ffdfec 100644 --- a/e2e/projectNewMenu.spec.ts +++ b/e2e/projectNewMenu.spec.ts @@ -101,6 +101,48 @@ test("uses the single project's type in the keyboard New popup", async ({ workbe ).toBeVisible(); }); +test("keeps the search aligned and visible while scrolling the New popup", async ({ workbench: page }) => { + await page.setViewportSize({ width: 540, height: 320 }); + await page.evaluate(async () => { + const module = "/src/platform/project.ts"; + const { useProject } = await import(/* @vite-ignore */ module); + const settings = useProject.getState().settings; + useProject.setState({ + settings: { + ...settings, + appearance: { ...settings?.appearance, theme: "dark", syncWithOs: false, compactMode: true }, + }, + }); + }); + await expect(page.locator("html")).toHaveAttribute("data-compact", ""); + await page + .getByRole("toolbar", { name: "Tool windows", exact: true }) + .getByRole("button", { name: "Project", exact: true }) + .click(); + await page.locator('[data-project-path="/dev/acme-api"]').click(); + await page.keyboard.press("Meta+n"); + + const popup = page.getByRole("dialog", { name: "New", exact: true }); + const search = popup.getByRole("textbox", { name: "Search for file type" }); + const list = popup.getByRole("listbox", { name: "File types" }); + const selected = list.getByRole("option", { selected: true }); + await expect(search).toBeFocused(); + await expect(selected).toHaveCSS("height", "22px"); + await expect(search).toHaveCSS("height", "22px"); + const searchBox = (await search.boundingBox())!; + const listBox = (await list.boundingBox())!; + const firstLabel = (await selected.getByText("File", { exact: true }).boundingBox())!; + expect(searchBox.x).toBeCloseTo(firstLabel.x); + expect(searchBox.y + searchBox.height).toBeLessThan(listBox.y); + await expect.poll(() => list.evaluate((el) => el.scrollHeight - el.clientHeight)).toBeGreaterThan(0); + + await search.press("ArrowUp"); + await expect.poll(() => list.evaluate((el) => el.scrollTop)).toBeGreaterThan(0); + await expect(selected).toBeInViewport({ ratio: 1 }); + await expect(search).toBeFocused(); + await expect(search).toBeInViewport({ ratio: 1 }); +}); + test("names a file from a template and keeps keyboard kind selection visible in a short window", async ({ workbench: page, }) => { diff --git a/src/features/project-tree/NewPopup.module.css b/src/features/project-tree/NewPopup.module.css index 89babf4d7..80431d9c9 100644 --- a/src/features/project-tree/NewPopup.module.css +++ b/src/features/project-tree/NewPopup.module.css @@ -1,31 +1,33 @@ /* IDEA's New popup: search field over a list of file kinds. */ .popup { - width: 280px; + width: 304px; overflow: hidden; display: flex; flex-direction: column; - padding-bottom: 4px; + padding-bottom: var(--space-1); } .search { + flex: none; display: flex; align-items: center; - gap: var(--space-1-5); - height: var(--h-row); - padding: 0 10px; + gap: var(--space-2); + padding: var(--space-1); border-bottom: 1px solid var(--border-popup); - margin-bottom: 4px; + margin: 0 var(--space-3) var(--space-1); } .searchIcon { flex: none; color: var(--fg-muted); } -.input { +.search .input { flex: 1; min-width: 0; + height: var(--h-row); } .list { + --list-inset: var(--space-2); max-height: 420px; - height: auto; + font-size: var(--fs-ui); } .row { display: flex; @@ -53,8 +55,9 @@ } .shortcut { flex: none; - margin-left: 16px; + margin-left: var(--space-2); font-family: var(--font-keys); + font-size: var(--fs-small); color: var(--fg-muted); } .separator { @@ -63,7 +66,7 @@ background: var(--border-popup); } .empty { - padding: 6px 10px; + padding: var(--space-2) var(--space-3); color: var(--fg-faint); font-size: var(--fs-small); } diff --git a/src/features/project-tree/NewPopup.tsx b/src/features/project-tree/NewPopup.tsx index 4d0e85238..e6f834c17 100644 --- a/src/features/project-tree/NewPopup.tsx +++ b/src/features/project-tree/NewPopup.tsx @@ -53,7 +53,7 @@ function NewPopup({ at, items }: { at: { x: number; y: number }; items: MenuItem className={styles.popup} >
- +