Skip to content

Commit abaa0ad

Browse files
Keep settings controls visible in a narrow window (#7269)
1 parent 99fb676 commit abaa0ad

8 files changed

Lines changed: 43 additions & 30 deletions

File tree

‎apps/desktop/src/main/body.test.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ describe("ClassicMainBody", () => {
722722
expect(panels[1]?.dataset.minWidth).toBe("500");
723723
});
724724

725-
it("prefers a 700px settings panel without overflowing a narrower window", () => {
725+
it("lets the settings content panel shrink beside the sidebar", () => {
726726
mocks.currentTab = {
727727
active: true,
728728
pinned: false,
@@ -734,7 +734,7 @@ describe("ClassicMainBody", () => {
734734
render(<ClassicMainBody />);
735735

736736
const panels = screen.getAllByTestId("panel");
737-
expect(panels[1]?.dataset.minWidth).toBe("min(700px, 100%)");
737+
expect(panels[1]?.dataset.minWidth).toBeUndefined();
738738
});
739739

740740
it("unmounts hidden sidebar content when the panel is collapsed", () => {

‎apps/desktop/src/main/body.tsx‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ import {
4040
usesWindowsStyleTitleBar,
4141
useWindowControlsGutter,
4242
} from "~/shared/hooks/useWindowControlsGutter";
43-
import {
44-
boundedMinWidthPx,
45-
getMainContentMinWidth,
46-
} from "~/shared/main/layout-widths";
43+
import { getMainContentMinWidth } from "~/shared/main/layout-widths";
4744
import { useOpenNoteDialog } from "~/shared/open-note-dialog";
4845
import { useNewNote } from "~/shared/useNewNote";
4946
import { useSidebarNotes } from "~/sidebar/note-filter";
@@ -90,11 +87,7 @@ export function ClassicMainBody({
9087
leftSidebarPanelConstraintsRef.current = leftSidebarPanelConstraints;
9188

9289
const isOnboarding = currentTab?.type === "onboarding";
93-
const mainContentMinWidthPx = getMainContentMinWidth(currentTab);
94-
const mainContentMinWidth =
95-
currentTab?.type === "settings" && mainContentMinWidthPx != null
96-
? boundedMinWidthPx(mainContentMinWidthPx)
97-
: mainContentMinWidthPx;
90+
const mainContentMinWidth = getMainContentMinWidth(currentTab);
9891
const hasCustomSidebar = hasCustomSidebarTab(currentTab);
9992
const hasLeftSurfaceCustomSidebar =
10093
hasLeftSurfaceCustomSidebarTab(currentTab);

‎apps/desktop/src/settings/general/app-settings.test.tsx‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,17 @@ describe("AppSettingsView", () => {
4545
it("lets switch descriptions use the available row width", () => {
4646
renderAppSettings();
4747

48-
expect(
49-
screen.getByRole("switch", { name: "Start Anarlog at login" })
50-
.parentElement?.className,
51-
).not.toContain("w-48");
48+
const loginSwitch = screen.getByRole("switch", {
49+
name: "Start Anarlog at login",
50+
});
51+
52+
expect(loginSwitch.parentElement?.className).not.toContain("w-48");
53+
expect(loginSwitch.parentElement?.parentElement?.className).toContain(
54+
"min-w-0",
55+
);
56+
expect(loginSwitch.parentElement?.parentElement?.className).toContain(
57+
"w-full",
58+
);
5259
});
5360

5461
it("hides macOS-only Dock controls outside macOS", () => {

‎apps/desktop/src/settings/setting-row.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function SettingRow({
2424
const descriptionId = useId();
2525

2626
return (
27-
<div className="flex items-center justify-between gap-4">
27+
<div className="flex w-full min-w-0 items-center justify-between gap-4">
2828
<div className="min-w-0 flex-1">
2929
<h3 id={titleId} className="mb-1 text-sm font-medium">
3030
{title}
@@ -37,8 +37,9 @@ export function SettingRow({
3737
</div>
3838
<div
3939
className={cn([
40-
"flex shrink-0 justify-end",
41-
controlWidth === "fixed" && "w-48",
40+
"flex justify-end",
41+
controlWidth === "fixed" && "w-48 max-w-full min-w-0",
42+
controlWidth !== "fixed" && "shrink-0",
4243
])}
4344
>
4445
{children({

‎apps/desktop/src/shared/main/index.test.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ describe("StandardContentWrapper", () => {
6969
expect(screen.getAllByTestId("panel")).toHaveLength(1);
7070
expect(screen.getByTestId("panel").dataset.defaultSize).toBe("100");
7171
expect(screen.getByTestId("panel").dataset.minSize).toBe("35");
72+
expect(screen.getByTestId("panel").dataset.className).toContain("min-w-0");
73+
expect(
74+
screen.getByTestId("panel-group").parentElement?.className,
75+
).toContain("min-w-0");
76+
expect(
77+
screen.getByTestId("panel-group").parentElement?.className,
78+
).toContain("w-full");
7279
expect(screen.getByTestId("main-area")).toBeTruthy();
7380
expect(
7481
document.querySelector("[data-chat-floating-anchor]")?.className,

‎apps/desktop/src/shared/main/index.tsx‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,16 @@ export function StandardContentWrapper({
2626
noBorder?: boolean;
2727
}) {
2828
return (
29-
<div className="flex h-full flex-col">
30-
<ResizablePanelGroup direction="vertical" className="min-h-0 flex-1">
31-
<ResizablePanel defaultSize={100} minSize={35} className="min-h-0">
29+
<div className="flex h-full w-full min-w-0 flex-col">
30+
<ResizablePanelGroup
31+
direction="vertical"
32+
className="min-h-0 min-w-0 flex-1"
33+
>
34+
<ResizablePanel
35+
defaultSize={100}
36+
minSize={35}
37+
className="min-h-0 min-w-0"
38+
>
3239
<MainPanel fill floatingButton={floatingButton} noBorder={noBorder}>
3340
{children}
3441
</MainPanel>
@@ -54,14 +61,14 @@ function MainPanel({
5461
return (
5562
<div
5663
className={cn([
57-
"relative flex min-h-0 flex-1 flex-col",
64+
"relative flex min-h-0 min-w-0 flex-1 flex-col",
5865
fill && "h-full",
5966
])}
6067
>
6168
<div
6269
data-chat-floating-anchor
6370
className={cn([
64-
"bg-card @container relative flex min-h-0 flex-1 flex-col overflow-hidden",
71+
"bg-card @container relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden",
6572
isMacos && "rounded-xl",
6673
!noBorder && "border-border border",
6774
])}

‎apps/desktop/src/shared/main/layout-widths.test.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import {
77
} from "./layout-widths";
88

99
describe("layout-widths", () => {
10-
it("keeps a settings surface preference without overflowing its parent", () => {
11-
expect(getMainContentMinWidth({ type: "settings" })).toBe(
12-
SETTINGS_SURFACE_MIN_WIDTH_PX,
13-
);
10+
it("does not force a 700px inner settings panel beside the sidebar", () => {
11+
expect(getMainContentMinWidth({ type: "settings" })).toBeUndefined();
12+
});
13+
14+
it("caps a preferred min-width so it cannot exceed its parent", () => {
1415
expect(boundedMinWidthPx(SETTINGS_SURFACE_MIN_WIDTH_PX)).toBe(
1516
"min(700px, 100%)",
1617
);

‎apps/desktop/src/shared/main/layout-widths.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ export function getMainContentMinWidth(tab: Pick<Tab, "type"> | null) {
1717
if (tab?.type === "automations") {
1818
return AUTOMATIONS_SURFACE_MIN_WIDTH_PX;
1919
}
20-
if (tab?.type === "settings") {
21-
return SETTINGS_SURFACE_MIN_WIDTH_PX;
22-
}
2320
return usesNoteSurfaceMinWidth(tab) ? NOTE_SURFACE_MIN_WIDTH_PX : undefined;
2421
}
2522

0 commit comments

Comments
 (0)