diff --git a/webviews/src/pages/editor/styles.css b/webviews/src/pages/editor/styles.css index 2b4aa16f8dcd..78f380155621 100644 --- a/webviews/src/pages/editor/styles.css +++ b/webviews/src/pages/editor/styles.css @@ -155,12 +155,22 @@ body { background: var(--cmux-editor-background); } -/* Cmd-F: the shared find pill (ui/findPill.css) at the top right, where every pane's sits. */ +/* Cmd-F: the shared find pill (ui/findPill.css) at the top right, where every pane's sits. The + left inset bounds it too: it wants about 390px, so in a narrower editor its rows and fields give + way instead of the pill running off the left edge. The band beside it is click-through. */ .ed-find { position: absolute; top: var(--find-pill-inset, 10px); right: var(--find-pill-inset, 10px); + left: var(--find-pill-inset, 10px); z-index: var(--layer-overlay); + display: flex; + justify-content: flex-end; + pointer-events: none; +} +.ed-find > .find-pill, +.ed-find .find-pill__row { + min-width: 0; } .ed-status { diff --git a/webviews/test/editor-find-narrow.test.tsx b/webviews/test/editor-find-narrow.test.tsx new file mode 100644 index 000000000000..1adea4acb7f7 --- /dev/null +++ b/webviews/test/editor-find-narrow.test.tsx @@ -0,0 +1,89 @@ +// The code editor's find pill in a narrow pane: it wants about 390px, so in a 360px editor it must +// shrink inside the pane (its fields give way) instead of running off the left edge, where the +// gallery showed it cut at x≈-39 with the placeholder read as "place". Every control stays inside +// the pill too, in both modes: Cmd-F's one row and Replace's two. +// +// Real Chromium from Playwright; CI fails the file when it cannot launch (requireBrowserLane). +import { afterAll, beforeAll, describe, expect, setDefaultTimeout, test } from "bun:test"; +import { readFileSync } from "node:fs"; +import path from "node:path"; +import { renderToStaticMarkup } from "react-dom/server"; +import { chromium, type Browser } from "playwright"; +import { Icon } from "../src/icons"; +import { FindPill } from "../src/ui/FindPill"; +import { requireBrowserLane } from "./support/requireBrowserLane"; + +await requireBrowserLane("editor-find-narrow.test.tsx", async () => { + setDefaultTimeout(60_000); + const src = path.resolve(import.meta.dir, "../src"); + const css = ["ui/findPill.css", "pages/editor/styles.css"] + .map((file) => readFileSync(path.join(src, file), "utf8")) + .join("\n"); + + // What EditorFindBar renders, in English. The bar itself reads its EditorFind through + // useSyncExternalStore, which static rendering can't run. + const none = () => undefined; + const bar = (replaceOpen: boolean) => + renderToStaticMarkup( +