Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (agy): let a CollapsibleSection label wrap once its summary is hidden (#3853)

[._.]/ Adam Eivy4ad64fbb5b45
diff --git a/client/src/components/ui/CollapsibleSection.jsx b/client/src/components/ui/CollapsibleSection.jsx
index d7604a2a43..289390b916 100644
--- a/client/src/components/ui/CollapsibleSection.jsx
+++ b/client/src/components/ui/CollapsibleSection.jsx
@@ -11,9 +11,10 @@ import { ChevronDown, ChevronRight } from 'lucide-react';
// to one line instead of wrapping into a paragraph-tall header on a phone.
//
// Deliberately NOT here: a per-site `text-left` (the base-layer rule in
-// index.css already left-aligns wrapped flex-button labels), animation,
-// nesting support, or a controlled `open`/`onOpenChange` pair — every current
-// call site owns its open state internally.
+// index.css already left-aligns wrapped flex-button labels), animation, or
+// nesting support. Open state defaults to internal — the controlled
+// `open`/`onOpenChange` pair below is opt-in for the one call site that has to
+// drive it from outside the header.
//
// `size` picks between the tones that already exist in the app rather than
// unifying them; pick the one that matches the call site's neighbours.
@@ -80,10 +81,11 @@ export default function CollapsibleSection({
>
<Chevron size={tone.iconSize} className="shrink-0" />
{Icon ? <Icon size={tone.iconSize} className="shrink-0" /> : null}
- {/* The label only refuses to shrink when there's a summary competing
- for the same line — otherwise a long standalone label would
- overflow the header instead of wrapping. */}
- <span className={`${summary ? 'shrink-0' : 'min-w-0'} ${tone.label}`.trim()}>{label}</span>
+ {/* The label only refuses to shrink while a summary is actually on the
+ line beside it — otherwise (no summary, or expanded so the summary
+ is hidden) a long label would overflow the header instead of
+ wrapping. */}
+ <span className={`${summary && !open ? 'shrink-0' : 'min-w-0'} ${tone.label}`.trim()}>{label}</span>
{summary && !open
? <span className={`min-w-0 truncate ${tone.summary}`.trim()}>{summary}</span>
: null}
diff --git a/client/src/components/ui/CollapsibleSection.test.jsx b/client/src/components/ui/CollapsibleSection.test.jsx
index 24593a9e15..785e1dad19 100644
--- a/client/src/components/ui/CollapsibleSection.test.jsx
+++ b/client/src/components/ui/CollapsibleSection.test.jsx
@@ -45,6 +45,21 @@ describe('CollapsibleSection', () => {
expect(screen.queryByText(': Wedding, Rainy day')).not.toBeInTheDocument();
});
+ it('lets the label shrink once the summary is no longer beside it', () => {
+ render(
+ <CollapsibleSection label="Outfits" summary=": Wedding">body</CollapsibleSection>,
+ );
+ const button = screen.getByRole('button', { name: /Outfits/ });
+ const label = screen.getByText('Outfits');
+ expect(label).toHaveClass('shrink-0');
+
+ // Expanded hides the summary, so nothing competes for the line and a long
+ // label must be free to wrap rather than overflow the header.
+ fireEvent.click(button);
+ expect(label).toHaveClass('min-w-0');
+ expect(label).not.toHaveClass('shrink-0');
+ });
+
it('honors defaultOpen', () => {
render(
<CollapsibleSection label="Analysis Summary" defaultOpen>