mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-25 08:02:56 +00:00
fix(diff): keep toolbar status visible in narrow editors (#4527)
In a diff editor narrower than 380px the toolbar wraps and keeps the change count visible; the viewer-mode, collapse and scroll-sync toggles move out of the toolbar there and stay in the gear menu.
This commit is contained in:
@@ -19,6 +19,33 @@ async function openChain(page: Page) {
|
||||
return toolbar;
|
||||
}
|
||||
|
||||
test("a narrow diff keeps navigation, settings and the difference count visible", async ({ workbench: page }) => {
|
||||
const toolbar = await openChain(page);
|
||||
await page.setViewportSize({ width: 400, height: 600 });
|
||||
const clipped = await toolbar.evaluate((bar) => {
|
||||
const bounds = bar.getBoundingClientRect();
|
||||
const items = [...bar.querySelectorAll("button, span")].filter(
|
||||
(el) => el.matches("button") || el.textContent === "1 difference",
|
||||
);
|
||||
return items.flatMap((el) => {
|
||||
const box = el.getBoundingClientRect();
|
||||
if (el.matches("button") && !box.width) return [];
|
||||
return !box.width ||
|
||||
box.right > bounds.right + 1 ||
|
||||
box.bottom > bounds.bottom + 1 ||
|
||||
el.scrollWidth > el.clientWidth + 1
|
||||
? [el.getAttribute("aria-label") || el.textContent]
|
||||
: [];
|
||||
});
|
||||
});
|
||||
expect(clipped).toEqual([]);
|
||||
await toolbar.getByRole("button", { name: "Settings", exact: true }).click();
|
||||
await page.getByRole("menuitemcheckbox", { name: "Unified Viewer", exact: true }).click();
|
||||
await expect(toolbar.locator("..").locator(".cm-editor")).toHaveCount(1);
|
||||
await toolbar.getByRole("button", { name: "Next Difference", exact: true }).click();
|
||||
await expect(toolbar).toContainText("1 of 1 differences");
|
||||
});
|
||||
|
||||
test("maximizes a diff preview tab and restores its previous layout", async ({ workbench: page }) => {
|
||||
const toolbar = await openChain(page);
|
||||
const viewer = toolbar.locator("..");
|
||||
|
||||
@@ -47,9 +47,22 @@
|
||||
}
|
||||
}
|
||||
@container diff-editor (max-width: 380px) {
|
||||
.toolbar > .sep {
|
||||
.toolbar {
|
||||
height: auto;
|
||||
min-height: var(--h-header);
|
||||
flex-wrap: wrap;
|
||||
align-content: center;
|
||||
padding-block: var(--space-0-5);
|
||||
}
|
||||
.toolbar > .sep,
|
||||
.toolbar > .inlineOption {
|
||||
display: none;
|
||||
}
|
||||
.toolbar > .count {
|
||||
flex: 1 1 auto;
|
||||
order: 1;
|
||||
text-align: end;
|
||||
}
|
||||
}
|
||||
.labels {
|
||||
flex: none;
|
||||
|
||||
@@ -1447,6 +1447,7 @@ export function DiffEditor({
|
||||
{canSwap && <IconButton icon="swap-panels" title="Swap Sides" size="small" onClick={() => void swapSides()} />}
|
||||
<IconButton
|
||||
icon="diff-side-by-side"
|
||||
className={styles.inlineOption}
|
||||
title="Side-by-side Viewer"
|
||||
size="small"
|
||||
pressed={viewMode === "split"}
|
||||
@@ -1455,6 +1456,7 @@ export function DiffEditor({
|
||||
/>
|
||||
<IconButton
|
||||
icon="diff-unified"
|
||||
className={styles.inlineOption}
|
||||
title="Unified Viewer"
|
||||
size="small"
|
||||
pressed={viewMode === "unified"}
|
||||
@@ -1478,6 +1480,7 @@ export function DiffEditor({
|
||||
/>
|
||||
<IconButton
|
||||
icon="collapse-all"
|
||||
className={styles.inlineOption}
|
||||
title="Collapse Unchanged Fragments"
|
||||
size="small"
|
||||
pressed={opts.collapse}
|
||||
@@ -1486,6 +1489,7 @@ export function DiffEditor({
|
||||
{viewMode === "split" && (
|
||||
<IconButton
|
||||
icon="lock"
|
||||
className={styles.inlineOption}
|
||||
title="Synchronize Scrolling"
|
||||
size="small"
|
||||
pressed={opts.syncScroll}
|
||||
|
||||
Reference in New Issue
Block a user