mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 08:03:19 +00:00
fix(search): keep Find in Files footer actions together (#5192)
Keep the shortcut hint beside Open in Find Window and keep Replace All beside the current selection action when the popup wraps. A separator and a smaller keyboard hint give the footer its own visual hierarchy. The popup handles its advertised shortcut when either search field has focus.
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<HTMLDivElement>) => {
|
||||
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() {
|
||||
)}
|
||||
</div>
|
||||
<footer className={styles.footer}>
|
||||
<Checkbox
|
||||
checked={s.newTab}
|
||||
onChange={setFindPopupNewTab}
|
||||
label={<Mnemonic text={tx("Open results in new tab")} char="B" />}
|
||||
/>
|
||||
{s.replace && <Checkbox checked={previewMode} onChange={setPreviewMode} label="Preview" />}
|
||||
<div className={styles.footerOptions}>
|
||||
<Checkbox
|
||||
checked={s.newTab}
|
||||
onChange={setFindPopupNewTab}
|
||||
label={<Mnemonic text={tx("Open results in new tab")} char="B" />}
|
||||
/>
|
||||
{s.replace && <Checkbox checked={previewMode} onChange={setPreviewMode} label="Preview" />}
|
||||
</div>
|
||||
{navigationHint && <span className={styles.hint}>{navigationHint}</span>}
|
||||
<span className={styles.spacer} />
|
||||
{s.replace && progress && (
|
||||
<span className={styles.hint} aria-live="polite">
|
||||
{tx`Replacing… ${progress.done}/${progress.total} files`}
|
||||
</span>
|
||||
{s.replace && (progress || running) && (
|
||||
<div className={styles.footerGroup}>
|
||||
{progress && (
|
||||
<span className={styles.hint} aria-live="polite">
|
||||
{tx`Replacing… ${progress.done}/${progress.total} files`}
|
||||
</span>
|
||||
)}
|
||||
{running && (
|
||||
<Button onClick={() => running.cancel()}>
|
||||
<T>Stop</T>
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{s.replace && running && (
|
||||
<Button onClick={() => running.cancel()}>
|
||||
<T>Stop</T>
|
||||
<div className={styles.footerGroup}>
|
||||
<kbd className={styles.okHint}>{formatBinding(hostBinding("Meta+Enter"))}</kbd>
|
||||
<Button disabled={!query?.pattern} onClick={pin}>
|
||||
<T>Open in Find Window</T>
|
||||
</Button>
|
||||
)}
|
||||
<span className={styles.okHint}>{formatBinding(hostBinding("Meta+Enter"))}</span>
|
||||
<Button disabled={!query?.pattern} onClick={pin}>
|
||||
<T>Open in Find Window</T>
|
||||
</Button>
|
||||
</div>
|
||||
{s.replace && (
|
||||
<>
|
||||
<div className={styles.footerGroup}>
|
||||
<Button
|
||||
title={formatBinding("Shift+Alt+Enter")}
|
||||
disabled={stale || !rows.length || busy || state.status === "searching"}
|
||||
@@ -945,7 +963,7 @@ function FindInFilesDialog() {
|
||||
<Button variant="primary" disabled={stale || !selected || busy} onClick={() => void replaceSelected()}>
|
||||
{pendingSelected > 1 ? txt(`Replace ${pendingSelected} Occurrences`) : <T>Replace</T>}
|
||||
</Button>
|
||||
</>
|
||||
</div>
|
||||
)}
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user