mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 08:03:19 +00:00
fix(project): align the New file type picker (#5004)
The keyboard New popup aligns the search icon and text with the options below it. The search divider has side margins, and the search field keeps its height in short windows while the list scrolls. The wider list and smaller shortcut text let the full Scratch File label fit alongside its Windows shortcut.
This commit is contained in:
@@ -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,
|
||||
}) => {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ function NewPopup({ at, items }: { at: { x: number; y: number }; items: MenuItem
|
||||
className={styles.popup}
|
||||
>
|
||||
<div className={styles.search}>
|
||||
<Icon name="search" size={14} className={styles.searchIcon} />
|
||||
<Icon name="search" size={16} className={styles.searchIcon} />
|
||||
<Input
|
||||
variant="bare"
|
||||
data-autofocus
|
||||
|
||||
Reference in New Issue
Block a user