дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 09:11:10 +02:00
feat(search): make Search Everywhere resizable from all edges and corners (#7373)
Search Everywhere opened at a fixed 700 px width with its height capped at 600 px, clipping long paths, containers and previews on wide monitors. Dialog's resizable="both" now resizes from all eight edges and corners (the opposite edge stays put), not only the bottom-right grip, and Search Everywhere uses it with a remembered size (openidea.search.everywhereSize.v1, clamped to its minimum). The other resizable dialogs get the edge handles too. Covered by Dialog and Search Everywhere tests. Co-authored-by: elfadl <[email protected]>
Цей коміт міститься в:
1 джерело
54ce048ec9
коміт
fdc4df4752
8 files changed
+408
-51
No files matched your search
@@ -87,6 +87,7 @@ beforeEach(() => {
|
||||
useFindPopup.setState({ caseSensitive: false, wholeWord: false, isRegex: false });
|
||||
localStorage.removeItem(TEXT_SEARCH_OPTIONS_KEY);
|
||||
localStorage.removeItem(RECENT_FILES_SIZE_KEY);
|
||||
localStorage.removeItem("openidea.search.everywhereSize.v1");
|
||||
vi.mocked(openLocation).mockClear();
|
||||
});
|
||||
|
||||
@@ -1027,3 +1028,46 @@ it("restarts a custom query restored before its debounce expires", async () => {
|
||||
expect(screen.getByText("Fresh route")).toBeVisible();
|
||||
act(remove);
|
||||
});
|
||||
|
||||
describe("Search Everywhere resize", () => {
|
||||
it("is resizable, persists its size globally, and keeps that size when empty", async () => {
|
||||
render(<SearchEverywhereOverlay />);
|
||||
act(() => showSearchEverywhere("all"));
|
||||
await tick();
|
||||
|
||||
const dialog = screen.getByRole("dialog", { name: "Search Everywhere" });
|
||||
expect(dialog).not.toHaveAttribute("data-resized");
|
||||
expect(within(dialog).getByRole("separator", { name: "Resize" })).toBeInTheDocument();
|
||||
|
||||
fireEvent.pointerDown(within(dialog).getByRole("separator", { name: "Resize" }), {
|
||||
button: 0,
|
||||
clientX: 0,
|
||||
clientY: 0,
|
||||
});
|
||||
fireEvent.pointerMove(window, { buttons: 1, clientX: 820, clientY: 520 });
|
||||
fireEvent.pointerUp(window);
|
||||
|
||||
expect(dialog).toHaveAttribute("data-resized");
|
||||
expect([dialog.style.width, dialog.style.height]).toEqual(["820px", "520px"]);
|
||||
expect(JSON.parse(localStorage.getItem("openidea.search.everywhereSize.v1")!)).toEqual({ w: 820, h: 520 });
|
||||
|
||||
act(() => hideSearchEverywhere());
|
||||
act(() => showSearchEverywhere("classes", { query: "" }));
|
||||
await tick();
|
||||
|
||||
const reopened = screen.getByRole("dialog", { name: "Search Everywhere" });
|
||||
expect(reopened).toHaveAttribute("data-resized");
|
||||
expect([reopened.style.width, reopened.style.height]).toEqual(["820px", "520px"]);
|
||||
});
|
||||
|
||||
it("clamps stored sizes to the minimum dimensions", async () => {
|
||||
localStorage.setItem("openidea.search.everywhereSize.v1", JSON.stringify({ w: 200, h: 100 }));
|
||||
render(<SearchEverywhereOverlay />);
|
||||
act(() => showSearchEverywhere("classes", { query: "" }));
|
||||
await tick();
|
||||
|
||||
const dialog = screen.getByRole("dialog", { name: "Search Everywhere" });
|
||||
expect(dialog).toHaveAttribute("data-resized");
|
||||
expect([dialog.style.width, dialog.style.height]).toEqual(["480px", "240px"]);
|
||||
});
|
||||
});
|
||||
@@ -147,11 +147,26 @@
|
||||
/* `auto`, not `1`: without the preview `.content` has no definite height, and a 0% basis there
|
||||
collapses the list in the system WebKit of macOS 15 instead of using its inline height. */
|
||||
flex: 1 1 auto;
|
||||
height: var(--se-list-height, auto);
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 0 0 8px;
|
||||
}
|
||||
.dialog[data-resized] {
|
||||
max-height: calc(100vh - 24px);
|
||||
}
|
||||
.dialog[data-resized] .content {
|
||||
flex: 1 1 0%;
|
||||
min-height: 0;
|
||||
}
|
||||
.dialog[data-resized] .withPreview {
|
||||
height: auto;
|
||||
}
|
||||
.dialog[data-resized] .results {
|
||||
flex: 1 1 0%;
|
||||
height: auto;
|
||||
}
|
||||
.list {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
@@ -296,7 +311,7 @@
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
height: 30px;
|
||||
padding: 0 12px;
|
||||
padding: 0 20px 0 12px;
|
||||
background: var(--se-bg-header);
|
||||
border-top: 1px solid var(--border-popup);
|
||||
color: var(--fg-subtle);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { writeClipboardText } from "@/platform/clipboard";
|
||||
import { onSearchCategoriesChanged, onEndpointsChanged } from "@/workbench/contributions";
|
||||
import { useFilePresentation } from "@/ui/filePresentation";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
import { useEffect, useMemo, useRef, useState, type KeyboardEvent, type MouseEvent } from "react";
|
||||
import { useEffect, useMemo, useRef, useState, type CSSProperties, type KeyboardEvent, type MouseEvent } from "react";
|
||||
import clsx from "clsx";
|
||||
import { actionToggled, executeAction, executeActionFrom, getAction } from "@/platform/actions";
|
||||
import { onIdeEvent, type ProjectFileSet } from "@/platform/ipc";
|
||||
@@ -66,10 +66,14 @@ import {
|
||||
type SectionId,
|
||||
} from "./model";
|
||||
import {
|
||||
SE_MIN_HEIGHT,
|
||||
SE_MIN_WIDTH,
|
||||
hideSearchEverywhere,
|
||||
loadSearchEverywhereSize,
|
||||
onSearchEverywhereQuery,
|
||||
pushRecentAction,
|
||||
pushSearchHistory,
|
||||
saveSearchEverywhereSize,
|
||||
searchHistory,
|
||||
selectSearchEverywhereTab,
|
||||
setIncludeNonProject,
|
||||
@@ -134,6 +138,7 @@ const INITIAL_SELECTION: Selection = { key: null, anchorKey: null, lead: -1, anc
|
||||
function SearchEverywhereDialog() {
|
||||
const tx = useTx();
|
||||
const rowHeight = useRowHeight(ROW);
|
||||
const [initialSize] = useState(loadSearchEverywhereSize);
|
||||
const tab = useSearchEverywhere((s) => s.tab);
|
||||
const hint = hintFor(tab, tx);
|
||||
const [tabs, setTabs] = useState(searchTabs);
|
||||
@@ -586,7 +591,7 @@ function SearchEverywhereDialog() {
|
||||
<div
|
||||
ref={listRef}
|
||||
className={styles.results}
|
||||
style={{ height: rows.length && !preview ? listHeight + 8 : undefined }}
|
||||
style={rows.length && !preview ? ({ "--se-list-height": `${listHeight + 8}px` } as CSSProperties) : undefined}
|
||||
>
|
||||
{rows.length > 0 && (
|
||||
<List<SeRow>
|
||||
@@ -643,6 +648,11 @@ function SearchEverywhereDialog() {
|
||||
open
|
||||
onClose={close}
|
||||
width={700}
|
||||
resizable="both"
|
||||
minWidth={SE_MIN_WIDTH}
|
||||
minHeight={SE_MIN_HEIGHT}
|
||||
initialSize={initialSize}
|
||||
onResized={saveSearchEverywhereSize}
|
||||
position="top"
|
||||
transparentBackdrop
|
||||
aria-label={tx("Search Everywhere")}
|
||||
|
||||
@@ -31,6 +31,20 @@ interface SeState {
|
||||
|
||||
const PREVIEW_KEY = "openidea.search.everywherePreview.v1";
|
||||
const FILTERS_KEY = "openidea.search.everywhereFilters.v1";
|
||||
const SIZE_KEY = "openidea.search.everywhereSize.v1";
|
||||
export const SE_MIN_WIDTH = 480;
|
||||
export const SE_MIN_HEIGHT = 240;
|
||||
|
||||
export function loadSearchEverywhereSize(): { w: number; h: number } | null {
|
||||
const v = loadJson<{ w?: unknown; h?: unknown } | null>(SIZE_KEY, null);
|
||||
return typeof v?.w === "number" && typeof v.h === "number" && Number.isFinite(v.w + v.h) && v.w > 0 && v.h > 0
|
||||
? { w: Math.max(SE_MIN_WIDTH, v.w), h: Math.max(SE_MIN_HEIGHT, v.h) }
|
||||
: null;
|
||||
}
|
||||
|
||||
export function saveSearchEverywhereSize(size: { w: number; h: number }) {
|
||||
saveJson(SIZE_KEY, size);
|
||||
}
|
||||
|
||||
export const useSearchEverywhere = create<SeState>(() => ({
|
||||
open: false,
|
||||
|
||||
Reference in new issue
Заблокувати користувача