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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): count renderable children, not array length (#4170)
Adam Eivy587c0aeab2bf
diff --git a/client/src/components/ui/CollapsibleText.jsx b/client/src/components/ui/CollapsibleText.jsxindex dcf076738c..0655cd6b65 100644--- a/client/src/components/ui/CollapsibleText.jsx+++ b/client/src/components/ui/CollapsibleText.jsx@@ -1,4 +1,4 @@-import { useState, useRef, useEffect } from 'react';+import { Children, useState, useRef, useEffect } from 'react';import { ChevronDown, ChevronUp } from 'lucide-react';// Tailwind scans source for literal class names, so the clamp variants must@@ -92,9 +92,14 @@ export default function CollapsibleText({// happen to be blank" — a caller doing `<CollapsibleText text={fallback}>// {items.map(…)}</CollapsibleText>` over an empty list must get the text// fallback, not an empty capped box with its `text` silently dropped.- const hasChildren = Array.isArray(children)- ? children.length > 0- : children != null && children !== false && children !== '';+ // Array *length* is the wrong signal: `items.map(i => i.show ? <Row/> : null)`+ // over an all-hidden list yields `[null]` — length 1, renders nothing.+ // `Children.toArray` drops exactly those non-rendering placeholders (`null`,+ // `undefined`, booleans) and flattens nested arrays; empty/whitespace strings+ // survive it, so they're filtered here too.+ const hasChildren = Children.toArray(children).some(+ child => typeof child !== 'string' || child.trim() !== ''+ );useEffect(() => {if (expanded) return;diff --git a/client/src/components/ui/CollapsibleText.test.jsx b/client/src/components/ui/CollapsibleText.test.jsxindex 237c8453c7..b2fa107c79 100644--- a/client/src/components/ui/CollapsibleText.test.jsx+++ b/client/src/components/ui/CollapsibleText.test.jsx@@ -260,6 +260,27 @@ describe('CollapsibleText children (max-height) variant', () => {expect(document.getElementById('c9')).toHaveClass('line-clamp-2');});+ it('treats a list of non-rendering children as no children', () => {+ // `items.map(i => i.show ? <Row/> : null)` over an all-hidden list yields+ // `[null]` — length 1, renders nothing. Counting array length would take the+ // children path and drop `text` into an empty capped box.+ render(+ <CollapsibleText id="c9b" text="plain fallback">{[null, false, undefined, ' ']}</CollapsibleText>+ );+ expect(screen.getByText('plain fallback')).toBeInTheDocument();+ expect(document.getElementById('c9b')).toHaveClass('line-clamp-2');+ });++ it('takes the children path when a list renders even one child', () => {+ forceOverflow();+ render(+ <CollapsibleText id="c9c" text="plain fallback">{[null, <p key="a">real</p>]}</CollapsibleText>+ );+ expect(screen.getByText('real')).toBeInTheDocument();+ expect(screen.queryByText('plain fallback')).not.toBeInTheDocument();+ expect(document.getElementById('c9c')).not.toHaveClass('line-clamp-2');+ });+it('expands when focus lands inside the capped region', () => {// The cap is a scroll container with no visible scrollbar. Tabbing to a link// below it would scroll the preview to reveal the target with no way back,