diff --git a/e2e/searchPopupsNarrow.spec.ts b/e2e/searchPopupsNarrow.spec.ts index 723bfec04..e869ecbad 100644 --- a/e2e/searchPopupsNarrow.spec.ts +++ b/e2e/searchPopupsNarrow.spec.ts @@ -3,7 +3,7 @@ * header on screen: titles stay on one line and every header control lies inside the popup. */ import type { Page } from "@playwright/test"; -import { expect, stubDesktop, test } from "./fixtures"; +import { expect, openFromTree, stubDesktop, test } from "./fixtures"; const LONG_RESULT_PATH = "config/RegionalOrderReconciliationEndpointsForSandboxEnvironments.txt"; @@ -118,6 +118,49 @@ test.describe("search popups at the minimum window width", () => { await dialog.getByRole("button", { name: /Browse/ }).click({ trial: true }); }); + test("Replace in Files keeps its footer actions together as the window narrows", async ({ workbench: page }) => { + await page.setViewportSize({ width: 1120, height: 750 }); + await openFromTree(page, "settings.gradle.kts"); + await stubFindMatches(page); + await run(page, "find.replaceInPath"); + const dialog = page.getByRole("dialog", { name: "Replace in Files" }); + const search = dialog.getByRole("textbox", { name: "Text to find" }); + await search.fill("http://localhost:8080"); + await expect(dialog.locator("header [aria-live]")).toContainText("13 matches in 12 files"); + await search.press("Shift+ArrowDown"); + await search.press("Shift+ArrowDown"); + + const footer = dialog.locator("footer"); + const open = footer.getByRole("button", { name: "Open in Find Window", exact: true }); + const shortcut = footer.getByText(/^(Ctrl\+Enter|⌘↵)$/); + const replaceAll = footer.getByRole("button", { name: "Replace All", exact: true }); + const replaceSelected = footer.getByRole("button", { name: "Replace 3 Occurrences", exact: true }); + await expect(replaceSelected).toBeEnabled(); + for (const [width, height] of [ + [400, 500], + [1120, 750], + ] as const) { + await page.setViewportSize({ width, height }); + const [key, find, all, selected] = await Promise.all([ + shortcut.boundingBox(), + open.boundingBox(), + replaceAll.boundingBox(), + replaceSelected.boundingBox(), + ]); + if (!key || !find || !all || !selected) throw new Error("Expected all footer actions to be visible"); + expect(Math.abs(key.y + key.height / 2 - find.y - find.height / 2)).toBeLessThanOrEqual(1); + expect(Math.abs(all.y - selected.y)).toBeLessThanOrEqual(1); + await expectControlsFit(page); + await expect(footer).toBeInViewport({ ratio: 1 }); + await expect(shortcut).toHaveCSS("font-size", "12px"); + await open.click({ trial: true }); + await replaceSelected.click({ trial: true }); + } + await search.press("Meta+Enter"); + await expect(dialog).toBeHidden(); + await expect(page.getByRole("region", { name: "Find", exact: true })).toContainText("http://localhost:8080"); + }); + for (const id of [ "navigate.searchEverywhere", "navigate.searchText", diff --git a/src/features/search/find/FindInFiles.module.css b/src/features/search/find/FindInFiles.module.css index fb6c3c83c..7a0491c59 100644 --- a/src/features/search/find/FindInFiles.module.css +++ b/src/features/search/find/FindInFiles.module.css @@ -234,14 +234,31 @@ gap: var(--space-2); min-height: 46px; padding: 8px 20px; + border-top: 1px solid var(--border-popup); + background: var(--bg-frame, var(--bg-app)); } -.footer > button, -.footer > label { +.footerOptions, +.footerGroup { + display: flex; flex: none; - white-space: nowrap; + max-width: 100%; + align-items: center; + gap: var(--space-2); +} +.footerOptions { + flex-wrap: wrap; + margin-inline-end: auto; +} +.footerGroup > button { + flex-shrink: 1; + min-width: 0; + height: auto; + min-height: var(--h-button); + padding-block: var(--space-1); + white-space: normal; + overflow-wrap: anywhere; } .hint { - flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; @@ -249,6 +266,9 @@ color: var(--fg-faint); font-size: var(--fs-small); } +.footer > .hint { + flex: 1 1 0; +} .rowDone { opacity: 0.55; } @@ -286,6 +306,8 @@ .okHint { flex: none; color: var(--fg-faint); + font-family: var(--font-keys); + font-size: var(--fs-small); white-space: nowrap; } diff --git a/src/features/search/find/FindInFiles.tsx b/src/features/search/find/FindInFiles.tsx index ee4031331..f0db413ab 100644 --- a/src/features/search/find/FindInFiles.tsx +++ b/src/features/search/find/FindInFiles.tsx @@ -13,7 +13,7 @@ import { openEditorPaths, useEditorRegistry } from "@/editor/api"; import { executeAction } from "@/platform/actions"; import { setContext } from "@/platform/context"; import { t, useTxTemplate, tx, txPart } from "@/platform/i18n"; -import { formatBinding, hostBinding, shortcutLabel } from "@/platform/keymap"; +import { formatBinding, hostBinding, registerKeyClaim, shortcutLabel } from "@/platform/keymap"; import { call, commands, isTauri, onIdeEvent } from "@/platform/ipc"; import { useProject } from "@/platform/project"; import { useProjectModules } from "@/platform/projectRoots"; @@ -193,7 +193,19 @@ function FindInFilesDialog() { // Hidden popup actions (⌘G, F4, ⌥↓ …) win over the editor's bindings while this is set. useEffect(() => { setContext("findPopupOpen", true); - return () => setContext("findPopupOpen", false); + const release = registerKeyClaim( + (e) => + e.key === "Enter" && + (e.ctrlKey || e.metaKey) && + !e.altKey && + !e.shiftKey && + e.target instanceof HTMLElement && + e.target.matches("[data-find-field] :is(input, textarea)"), + ); + return () => { + release(); + setContext("findPopupOpen", false); + }; }, []); useEffect(() => { @@ -491,8 +503,7 @@ function FindInFilesDialog() { const onKeyDown = (e: KeyboardEvent) => { const target = e.target as HTMLElement; - const inField = - (target.tagName === "INPUT" || target.tagName === "TEXTAREA") && target.closest("[data-find-field]"); + const inField = target.matches("[data-find-field] :is(input, textarea)"); if (e.key === "Backspace" && e.altKey && e.shiftKey && !e.metaKey && !e.ctrlKey) { e.preventDefault(); clearOptions(); @@ -911,30 +922,37 @@ function FindInFilesDialog() { )}