mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 08:03:19 +00:00
fix(editor): fit wrapped tabs inside narrow splits (#4505)
Wrapped editor tabs fit inside their own split: a tab never grows past the strip, long labels truncate before the close button, and editor tabs use the 8px inline inset from the spacing scale.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { expect, openFromTree, test } from "./fixtures";
|
||||
|
||||
test("fits a long wrapped tab and its close button inside a narrow editor group", async ({ workbench: page }) => {
|
||||
const filename = "QuarterlyReconciliationAndCheckoutAllocation.test.ts";
|
||||
await page.setViewportSize({ width: 720, height: 760 });
|
||||
await openFromTree(page, "README.md");
|
||||
await page.evaluate(async (filename) => {
|
||||
const projectModule = "/src/platform/project.ts";
|
||||
const projectFilesModule = "/src/features/project-tree/fs.ts";
|
||||
const editorModule = "/src/editor/core/controller.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ projectModule);
|
||||
const { projectFs } = await import(/* @vite-ignore */ projectFilesModule);
|
||||
const { editorController, useTabs } = await import(/* @vite-ignore */ editorModule);
|
||||
const { project, settings } = useProject.getState();
|
||||
useProject.setState({
|
||||
settings: {
|
||||
...settings,
|
||||
editor: { ...settings?.editor, tabs: { ...settings?.editor?.tabs, multipleRows: true } },
|
||||
},
|
||||
});
|
||||
const path = `${project.root}/${filename}`;
|
||||
await projectFs(project.root).createFile(path);
|
||||
await editorController().openFilesIn([path], useTabs.getState().activePane, "right");
|
||||
}, filename);
|
||||
|
||||
const tab = page.getByRole("tab", { name: filename, exact: true });
|
||||
await expect(tab).toHaveAttribute("aria-selected", "true");
|
||||
await expect
|
||||
.poll(() =>
|
||||
tab.evaluate((element) => {
|
||||
const close = element.parentElement?.querySelector("[data-tab-close]");
|
||||
const strip = element.closest('[role="tablist"]');
|
||||
return !!close && !!strip && close.getBoundingClientRect().right <= strip.getBoundingClientRect().right;
|
||||
}),
|
||||
)
|
||||
.toBe(true);
|
||||
await tab.locator("..").getByRole("button", { name: "Close Tab", exact: true }).click();
|
||||
await expect(tab).toBeHidden();
|
||||
});
|
||||
@@ -13,6 +13,7 @@
|
||||
}
|
||||
/* Islands tabs: the selected tab is a rounded pill (tab-selected-bg / -border); no underline, no separators. */
|
||||
.editor {
|
||||
--tab-inline-padding: var(--space-2);
|
||||
height: var(--h-header);
|
||||
padding: 0 4px;
|
||||
}
|
||||
@@ -76,7 +77,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
padding: 0 10px;
|
||||
padding: 0 var(--tab-inline-padding, 10px);
|
||||
border-radius: inherit;
|
||||
white-space: nowrap;
|
||||
color: inherit;
|
||||
@@ -207,6 +208,12 @@
|
||||
.wrap .tab {
|
||||
height: calc(var(--h-header) - 6px);
|
||||
}
|
||||
.editor.wrap .tab {
|
||||
max-inline-size: 100%;
|
||||
}
|
||||
.editor.wrap .tabButton {
|
||||
min-inline-size: 0;
|
||||
}
|
||||
|
||||
/* Vertical strip (editor tabs placed left / right): a scrolling column of full-width tabs. */
|
||||
.vertical {
|
||||
@@ -266,7 +273,7 @@
|
||||
margin: 0 0 0 4px;
|
||||
}
|
||||
.closeLeft .closable .tabButton {
|
||||
padding: 0 10px 0 2px;
|
||||
padding: 0 var(--tab-inline-padding, 10px) 0 2px;
|
||||
}
|
||||
|
||||
/* drag & drop: the dragged tab is an empty slot the other tabs make room for (IDEA) */
|
||||
|
||||
Reference in New Issue
Block a user