Compare commits

...
Author SHA1 Message Date
l0ng-ai 2a415418e4 fix(settings): keep the current page visible in breadcrumbs 2026-11-22 18:07:25 +08:00
3 changed files with 63 additions and 13 deletions

No files matched your search

+33
View File
@@ -1,5 +1,38 @@
import { expect, test } from "./fixtures";
test("keeps the current settings page name readable when the path is wider than the pane", async ({
workbench: page,
}) => {
await page.keyboard.press("Meta+,");
const settings = page.getByRole("dialog", { name: "Settings", exact: true });
const search = settings.getByRole("textbox", { name: "Search settings" });
await search.fill("Maven");
const path = settings.getByLabel("Breadcrumb", { exact: true });
const parent = path.getByText("Build, Execution, Deployment", { exact: true });
const current = path.getByText("Maven", { exact: true });
await expect(current).toBeVisible();
await search.clear();
for (const width of [400, 560, 1120]) {
await page.setViewportSize({ width, height: 720 });
await expect
.poll(() =>
current.evaluate((label) => {
const box = label.getBoundingClientRect();
const trail = label.closest("[aria-label=Breadcrumb]")!.getBoundingClientRect();
return label.clientWidth >= label.scrollWidth && box.width > 0 && box.right <= trail.right + 1;
}),
)
.toBe(true);
}
await expect(parent).toBeInViewport({ ratio: 1 });
expect(await parent.evaluate((label) => label.scrollWidth <= label.clientWidth)).toBe(true);
await settings.getByRole("button", { name: "Back", exact: true }).click();
await expect(current).toBeHidden();
await settings.getByRole("button", { name: "Forward", exact: true }).click();
await expect(current).toBeVisible();
});
test("dirty settings keep scope labels and navigation inside the page header", async ({ workbench: page }) => {
await page.keyboard.press("Meta+,");
await expect(page.getByRole("dialog", { name: "Settings", exact: true })).toBeVisible();
@@ -101,19 +101,28 @@
color: var(--fg-strong);
font-weight: 600;
}
.crumb:last-child {
.parentCrumbs {
display: flex;
min-width: 0;
}
.crumb > span {
overflow: hidden;
text-overflow: ellipsis;
}
.crumb {
display: inline-flex;
align-items: center;
min-width: 0;
}
.crumbLabel {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
}
.currentCrumb {
flex: none;
max-width: 100%;
}
.crumbSep {
margin: 0 4px;
flex: none;
margin-inline: var(--space-1);
color: var(--fg-subtle);
}
.reset {
@@ -165,21 +165,29 @@ function PageHost({
const [headerSlot, setHeaderSlot] = useState<HTMLElement | null>(null);
if (!node) return <EmptyState title="Nothing found" icon="search" />;
const Body = page?.component;
const parents = crumbs.slice(0, -1);
return (
<PageContext.Provider value={ctx}>
<SettingsFormContext.Provider value={form}>
<SettingsPageFocusContext.Provider value={pageFocus}>
<SettingsHeaderSlotContext.Provider value={headerSlot}>
<div className={styles.pageHeader}>
<div className={styles.crumbs} aria-label={tx("Breadcrumb")}>
{crumbs.map((c, i) => (
<span key={i} className={styles.crumb}>
{i > 0 && <Icon name="chevron-right" size={12} className={styles.crumbSep} />}
<span>
<T>{c}</T>
</span>
<div className={styles.crumbs} aria-label={tx("Breadcrumb")} title={crumbs.map((c) => tx(c)).join(" › ")}>
{parents.length > 0 && (
<span className={styles.parentCrumbs}>
{parents.map((c, i) => (
<span key={i} className={styles.crumb}>
<span className={styles.crumbLabel}>
<T>{c}</T>
</span>
<Icon name="chevron-right" size={12} className={styles.crumbSep} />
</span>
))}
</span>
))}
)}
<span className={clsx(styles.crumbLabel, styles.currentCrumb)} aria-current="page">
<T>{node.title}</T>
</span>
</div>
<div ref={setHeaderSlot} className={styles.headerSlot} />
{dirty && (