packages/components · src/ui/sidebar/Sidebar.stx
Symptom
The Sidebar controller never runs. Collapse, width persistence, shell-selector pane offset and active-row sync are all dead in every app that renders <Sidebar>, because the emitted <script client> block is a syntax error and the browser discards the whole thing.
Cause
Lines 108 to 117 interpolate props into the client script with {{ }}, which substitutes the raw value with no quoting:
const collapsedProp = {{ collapsed }}
const collapsibleProp = {{ collapsible }}
const collapseModeProp = {{ collapseMode }}
const widthProp = {{ width }}
const minWidthProp = {{ minWidth }}
const persistKeyProp = {{ persistKey }}
const shellSelectorProp = {{ shellSelector }}
const widthVarProp = {{ widthVar }}
const collapsedClassProp = {{ collapsedClass }}
const followSystemAppearanceProp = {{ followSystemAppearance }}That is fine for the booleans and numbers and wrong for all five strings. Served HTML from a real dashboard, with persistKey, shellSelector and theme="macos" set:
const collapsedProp = false; // ok
const widthProp = 250; // ok
const collapseModeProp = hidden; // ReferenceError
const persistKeyProp = stacks-dashboard-sidebar; // parses as subtraction, ReferenceError
const shellSelectorProp = [data-stx-content]; // ReferenceError
const widthVarProp = --stx-sidebar-width; // SyntaxError
const collapsedClassProp = ; // SyntaxErrorconst collapsedClassProp = ; is unconditional: collapsedClass defaults to '', so every <Sidebar> emits it whether or not the consumer passes anything. One syntax error kills the entire block, so none of the ten assignments or the controller below them ever execute.
Reproduction
Render any <Sidebar :sections="…" theme="macos">, then look at the served HTML:
curl -s http://localhost:3002/ | grep -oE "const [A-Za-z]+Prop = ;"
# const collapsedClassProp = ;The DevTools console shows the parse failure and data-stx-sidebar never gains its controller behaviour, though the server-rendered rows and their hrefs work, which is why this hides well.
Suggested fix
JSON-encode the string props at the interpolation site, e.g. const collapsedClassProp = {{ JSON.stringify(collapsedClass) }}, or quote them. Worth checking the other components in the package for the same pattern, since nothing about it is Sidebar-specific.
Context
Found while fixing stacksjs/stacks#2279, where the dashboard's desktop sidebar rendered twelve empty section groups. That turned out to be a separate, unrelated prop-casing mistake on our side (stacksjs/stacks#2287). This one survived that fix.