mirror of
https://github.com/bitbaum/orangecat.git
synced 2026-12-05 00:08:14 +01:00
* fix(nav): the sidebar section label was not a control Clicking "Fund" / "Coordinate" / "Finance" did nothing — the label was an <h3> in a <div> and only the small chevron beside it carried the onClick. Three defects in the same family, all of them "the click did nothing": 1. The whole header row is now one <button>. A word that looks like a control but isn't reads as a dead click, and the arrow alone was a 44px target inside a full-width row of affordance. Second time this class landed in this sidebar (see ContextSwitcher, "not a dead pixel"), so it gets a guard rather than a third fix. 2. Collapsing the section holding the active page was a visual no-op: the render gate was `!isCollapsed || hasActiveItem`, so the chevron flipped to > while the list stayed open. An explicit toggle now wins. 3. Expanding every section silently reverted on reload — an empty saved set was read as "nothing was ever saved" and replaced by the defaults. Key presence, not set size, now decides. Also removes an SSOT violation found next door: buildInitialCollapsedSections branched on viewport (`isMobile ? section.priority > 3 : ...`), so on a phone the declared `defaultExpanded` was ignored in favour of a bare magic number and the same account saw different sections open on phone than on laptop. `defaultExpanded` is now the only input — which does mean Create and Fund start collapsed on mobile, matching the generator's documented intent. 5 tests, each verified by reverting the source and confirming it fails. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XeELB8b3N4JrT2asYL9WvE * chore(ci): gate the dead-label shape instead of fixing it a third time A heading sitting BESIDE a chevron-only toggle is a dead click: the visitor aims at the word and nothing happens, while the only real target is a small arrow in a full-width row of apparent affordance. This shape has now been reported twice in this one sidebar — on the ContextSwitcher avatar (two separate visitors, see its test's header) and on the Fund / Coordinate / Finance section headers, fixed in the previous commit. Per the never-twice rule the third occurrence should be impossible, not cheap, so the class gets a check rather than another sweep. check:dead-labels scans src/components for a heading followed within 12 lines by a <button> containing a Chevron, with no heading inside that button. The correct shape — label INSIDE the control, which HeaderNavigation already does — does not trip it. Zero hits across src/components today, so the sidebar was the last one. Mutation-proven both ways: restoring the pre-fix SidebarNavigation makes it exit 1 naming that exact line, and the current tree exits 0. A gate that has never been shown to fail is not a gate. Note for the fleet: this covers AUTHED surfaces, which the central ui-defect-audit.mjs structurally cannot reach — it renders public entry pages only. The two are complementary, not duplicates. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XeELB8b3N4JrT2asYL9WvE --------- Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
81 lines
2.9 KiB
JavaScript
81 lines
2.9 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* A heading that sits BESIDE a chevron-only toggle is a dead click.
|
|
*
|
|
* The shape:
|
|
*
|
|
* <div className="flex ... justify-between">
|
|
* <h3>Fund</h3> <- looks like the control, isn't
|
|
* <button onClick={toggle}> <- the only real target, ~44px wide
|
|
* <ChevronDown />
|
|
* </button>
|
|
* </div>
|
|
*
|
|
* The visitor aims at the word, nothing happens, and the arrow beside it is a
|
|
* small target in a full-width row of apparent affordance. This landed twice
|
|
* in the same sidebar — once on the ContextSwitcher avatar ("should be
|
|
* clickable", reported by two different visitors), once on the Fund /
|
|
* Coordinate / Finance section headers — so the class is closed by a gate
|
|
* instead of a third fix.
|
|
*
|
|
* The correct shape puts the label INSIDE the control, which is what
|
|
* HeaderNavigation already does:
|
|
*
|
|
* <button onClick={toggle} aria-expanded={open}>
|
|
* {item.name}
|
|
* <ChevronDown aria-hidden="true" />
|
|
* </button>
|
|
*
|
|
* Heuristic, so it is deliberately narrow: a heading, then within 12 lines a
|
|
* <button> containing a Chevron, and no heading inside that button. Anything
|
|
* that trips it is either the bug or a row that should be restructured anyway.
|
|
*/
|
|
import { readFileSync, readdirSync } from 'node:fs';
|
|
import { join, relative, extname } from 'node:path';
|
|
|
|
const ROOT = process.cwd();
|
|
const LOOKAHEAD = 12;
|
|
const HEADING = /<h[1-6]\b/;
|
|
const BUTTON = /<button\b/;
|
|
const CHEVRON = /<Chevron(Down|Up|Right|Left)\b/;
|
|
|
|
function walk(dir, files = []) {
|
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
if (entry.name === 'node_modules' || entry.name === '.next') continue;
|
|
const full = join(dir, entry.name);
|
|
if (entry.isDirectory()) walk(full, files);
|
|
else if (extname(entry.name) === '.tsx') files.push(full);
|
|
}
|
|
return files;
|
|
}
|
|
|
|
const violations = [];
|
|
for (const file of walk(join(ROOT, 'src', 'components'))) {
|
|
const lines = readFileSync(file, 'utf8').split('\n');
|
|
lines.forEach((line, i) => {
|
|
if (!HEADING.test(line)) return;
|
|
|
|
const text = lines.slice(i, i + LOOKAHEAD).join('\n');
|
|
const button = BUTTON.exec(text);
|
|
if (!button || !CHEVRON.test(text)) return;
|
|
|
|
// A heading AFTER the <button> means the label is inside the control —
|
|
// the correct shape, not a violation.
|
|
const headingInsideButton = [...text.matchAll(/<h[1-6]\b/g)].some(m => m.index > button.index);
|
|
if (headingInsideButton) return;
|
|
|
|
violations.push(`${relative(ROOT, file)}:${i + 1}\n ${line.trim()}`);
|
|
});
|
|
}
|
|
|
|
if (violations.length > 0) {
|
|
console.error(
|
|
`check:dead-labels — ${violations.length} heading(s) sitting beside a chevron-only toggle.\n` +
|
|
'Put the label inside the button so the whole row is the target:\n'
|
|
);
|
|
violations.forEach(v => console.error(` ${v}\n`));
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('check:dead-labels — no headings stranded beside a chevron-only toggle.');
|