From ac6f69d19aeaea799fb96ccc03ad9890320ae13c Mon Sep 17 00:00:00 2001 From: Roland Date: Wed, 5 Aug 2026 14:53:57 -0600 Subject: [PATCH] review: one figure for the point's room, and name the row-vs-chip contract Two review notes, no bugs. The geometry numbers disagreed with each other: I fixed one of the two "17.3px" mentions and left the other, and the figures were rendered px while ui.css states the same margin in design px, so three comments told three stories about one value. All of them now say 18.7px rendered and cross-reference the 1.0625rem in the stylesheet, with the unit stated. TagsLinkGroup peels `style` for the row and forwards the rest to each chip, which is right for `onClick` but is exactly the shape of the bug just fixed -- `className`, a Mantine Group prop, or a `data-*` meant for the row would all still land on every tag. `className` now goes with `style`, since it is unambiguously a row concern and the likeliest next one, and the split is documented next to the component. Not inverted to an explicit chipProps: that reshapes a working API with one call site. The contract is tested rather than only described, both halves in one test, because they are one destructure apart and the `style` half was wrong for as long as it existed. Verified by planting the regression: routing className back to the chips fails it. Co-Authored-By: Claude Opus 5 (1M context) --- app/src/Tags.js | 29 +++++++++++++++++++---------- app/src/Tags.test.js | 27 +++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/app/src/Tags.js b/app/src/Tags.js index c76ec9ec..d109e640 100644 --- a/app/src/Tags.js +++ b/app/src/Tags.js @@ -146,7 +146,11 @@ export function useTags() { * The link carries no margin of its own. It had `0.3em` either side, from when these were * Semantic labels that had none -- but a tag already reserves a `margin-left` in ui.css for * the point drawn outside its body, so that was 0.3em twice on top of the group's gap and - * the point's own room. Two tags sat 34.7px apart where the point needs 18.4px. + * the point's own room. Two tags sat 34.7px apart, of which the point needs 18.7px. + * + * Those are rendered px, measured in the browser at the default interface scale -- which is + * what a user sees, and why they are the numbers worth recording. The stylesheet states the + * same margin in design px, as `1.0625rem`; 17 x 1.1 is the 18.7 above. */ const TagLabelLink = ({name, props}) => { const to = getLocationStr({tag: name}, '/search'); @@ -164,19 +168,24 @@ export function useTags() { } } - const TagsLinkGroup = ({tagNames, style, ...props}) => { + /* + * Props here have two possible targets, and which one they take is part of the contract: + * + * `style` and `className` dress the ROW. Everything else reaches each CHIP, which is how + * `onClick` gets to a tag. + * + * `style` used to go down with the rest, so the dashboard's `marginTop` -- meant to space the + * row below its heading -- landed on all 34 tags and became 7.7px of extra space between + * every wrapped row of them. `className` is named alongside it because it is the same kind + * of thing and would fail the same way; a Mantine `Group` prop (`gap`, `wrap`, `justify`) or + * a `data-*` meant for the row still would, so add it here rather than at a call site. + */ + const TagsLinkGroup = ({tagNames, style, className, ...props}) => { if (!tagNames || tagNames.length === 0) { return ; } - /* - * `style` belongs to the group, not to each tag in it. It used to go down with the rest - * of the props to every chip, so the dashboard's `marginTop` -- meant to space the row - * below its heading -- landed on all 34 tags and became 7.7px of extra space between - * every wrapped row. The remaining props still reach the chips, which is how `onClick` - * gets there. - */ - return + return {tagNames.map(i => )} } diff --git a/app/src/Tags.test.js b/app/src/Tags.test.js index 77fded7d..24a7c588 100644 --- a/app/src/Tags.test.js +++ b/app/src/Tags.test.js @@ -132,7 +132,10 @@ describe('a tag chip', () => { * A tag already carries a `margin-left` in ui.css, and that one is structural: the point is * drawn outside the body, so the margin is the room it needs and cannot be reclaimed. Every * other gap in a row was decoration on top of it, and measured on the dashboard the tags were - * 34.7px apart horizontally and 18.5px apart vertically -- of which only 18.4px was the point. + * 34.7px apart horizontally and 18.5px apart vertically -- of which only 18.7px was the point. + * + * Rendered px throughout, measured in the browser at the default interface scale. ui.css states + * the same margin in design px, as `1.0625rem`. */ describe('a row of tags', () => { beforeEach(() => { @@ -149,7 +152,7 @@ describe('a row of tags', () => { /* * The link wrapper carried `0.3em` either side, from when these were Semantic labels * that had no margin of their own. It is 0.3em twice, plus the group's gap, plus the - * structural margin -- so two tags sat 34.7px apart where the point needs 17.3px, and + * structural margin -- so two tags sat 34.7px apart where the point needs 18.7px, and * a wall of tags on the dashboard read as loose. */ renderGroup(['Water', 'Archived']); @@ -181,4 +184,24 @@ describe('a row of tags', () => { expect(group).toBeTruthy(); expect(group.style.marginTop).toBe('0.5em'); }); + + it('dresses the row with a className, and still hands the rest to each tag', async () => { + /* + * `className` goes the same way as `style`, and for the same reason: it describes the row. + * It is tested rather than only documented because the two halves of this contract are + * one destructure apart, and the `style` half was wrong for as long as it existed. + * + * `onClick` is the other half, asserted here so a later tidy-up cannot route everything + * to the group and leave a wall of tags that no longer responds to a click. + */ + const onClick = jest.fn(); + renderGroup(['Water', 'Archived'], {className: 'tag-row', onClick}); + + const tag = await awaitColored('Water', BRIGHT); + expect(tag.className).not.toContain('tag-row'); + expect(tag.closest('.mantine-Group-root').className).toContain('tag-row'); + + tag.click(); + expect(onClick).toHaveBeenCalled(); + }); });