diff --git a/e2e/editorTabWrap.spec.ts b/e2e/editorTabWrap.spec.ts new file mode 100644 index 000000000..afe818e4b --- /dev/null +++ b/e2e/editorTabWrap.spec.ts @@ -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(); +}); diff --git a/src/ui/Tabs.module.css b/src/ui/Tabs.module.css index 073c6eb61..6e9ff26b5 100644 --- a/src/ui/Tabs.module.css +++ b/src/ui/Tabs.module.css @@ -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) */