Files
openidea/src/workbench/narrowWindow.ts
T
Taylor BurkeandTaylorBurke 34ae8acbf8 fix(window): lower the minimum window width to 400 px and let the UI fit it (#3440)
Tiling compositors ignore a client's minimum size, so a tile narrower than 800 px laid the webview out at 800 px and scaled it down. The minimum is now 400 px on every platform. At that width the welcome page header and action tiles wrap, the title bar's run and VCS widgets ellipsize instead of covering the toolbar, dialog footers wrap, and below 560 px the left and right tool windows collapse (their stripe buttons stay, the saved layout is unchanged, a wider window brings them back).

Closes #3046

Co-authored-by: TaylorBurke <TaylorBurke@users.noreply.github.com>
2026-11-15 04:02:55 +08:00

26 lines
1.2 KiB
TypeScript

/**
* In a window too narrow for the side tool windows (a tile on a tiling compositor), the left and
* right areas collapse so the editor keeps the width. Their stripe buttons stay; the saved layout
* is untouched, and a wider window puts them back. Keep the breakpoint in step with the
* `max-width: 560px` queries in Welcome.module.css and TitleBar.module.css.
*/
import { collapseSidesForNarrowWindow, restoreSidesAfterNarrowWindow, useToolWindowLayout } from "./toolwindows/store";
export const NARROW_WINDOW_QUERY = "(max-width: 560px)";
export function installNarrowWindow(): () => void {
if (typeof window.matchMedia !== "function") return () => {};
const query = window.matchMedia(NARROW_WINDOW_QUERY);
const apply = () => (query.matches ? collapseSidesForNarrowWindow() : restoreSidesAfterNarrowWindow());
query.addEventListener("change", apply);
// A project's layout loads afresh each time it opens, the same project again included.
const unsubscribe = useToolWindowLayout.subscribe((s, prev) => {
if (s.layoutLoads !== prev.layoutLoads && query.matches) collapseSidesForNarrowWindow();
});
apply();
return () => {
query.removeEventListener("change", apply);
unsubscribe();
};
}