review: one inset, and two tests that could not fail

Acting on the review of #625.  No bugs; four suggestions and three nits, of
which two were already handled and one needed no code.

The weld used three separate 8px literals -- the control's padding, its flex gap,
and the clear button's negative margins -- which had to stay in lockstep or the
button would drift past the border or back inside it.  They are one
`--searchbox-inset` now.

Cancelling the gap on the clear button's LEFT was a real side effect: when a
field is both `loading` and `clearable`, which SearchResultsInput allows, the DOM
order is input, spinner, clear, and the spinner ended up welded to the divider.
Only the right-hand padding is cancelled now; the 8px before the button stays,
and a case covers the pair.

`min-height` was still coming from `--ai-size`, so the rule only half-owned the
height it claimed to set -- true today by 0.15px, the field being 36.15 against a
36 minimum.  Unset now.

Two nits needed no code and are recorded as findings rather than changes.  The
clear button's corners are already square: the theme zeroes every
`--mantine-radius-*`, so there are no wedges to show against the field, and a
case now depends on that explicitly.  And a label-less button with BOTH `icon`
and `iconAfter` would stay mis-centred, but no call site writes one, so the limit
is documented instead of designed around.

Blank children now count as no label.  `toArray` drops null and booleans but
keeps `''` and whitespace, which would have left the glyph off-centre; no call
site does it today and the predicate should not depend on that.

Two corrections to my own work, both caught by planting:

The fragment case.  I wrote that `toArray` flattens fragments away to nothing and
tested `<></>` as unlabelled.  It does not -- it returns the fragment as one
child, so `<></>` is indistinguishable from real content.  The test now records
what actually happens, with `<>Delete</>` as the shape that occurs in practice.

The min-height assertion compared `--ai-size` -- which reads back as
`calc(2.25rem * var(--mantine-scale))` -- against a computed `36px`.  Two strings
that can never match, so it passed with the rule removed.  It compares resolved
lengths now, paired with an ordinary IconButton that DOES carry the minimum, so
its absence is attributable to this rule rather than to a Mantine default.  An
earlier attempt fabricated a shorter field by overriding the input's font size;
that was deleted, because a test that invents a layout the app never renders is
not evidence about this app.

1128 jest / 63 suites, 231 in ui-layout.cy.js, clean npm run build.  Confirmed
live: inset 8px, clear button 1px from the field edge, 8px from the input, at the
field's full inner height with no minimum of its own.
This commit is contained in:
Roland 2026-08-02 17:28:46 -06:00 • committed by lrnselfreliance
parent feaca59ce5
commit 83dc2ac82f
3 changed files with 153 additions and 10 deletions

View file

@ -307,10 +307,17 @@ html[data-theme="amber"] .wrolpi-pagination button[data-active] {
.wrolpi-searchbox-control {
display: flex;
align-items: center;
gap: 8px;
/*
* One inset for the padding, the gap between children, and the negative margin that
* welds the clear button to the edge. They were three separate 8px literals that had to
* stay in lockstep: changing the padding alone would have pushed the clear button past
* the border, and changing the gap alone would have re-inset it.
*/
--searchbox-inset: 8px;
gap: var(--searchbox-inset);
background: var(--panel);
border: 1px solid var(--border);
padding: 0 8px;
padding: 0 var(--searchbox-inset);
}
.wrolpi-searchbox-control:focus-within {
@ -357,20 +364,26 @@ html[data-theme="amber"] .wrolpi-searchbox-control:focus-within {
* the field: measured on the QA Pi, zero gap to the input, zero to the outer edge, and the
* full 44px height.
*
* Negative margins rather than removing the control's padding: the padding is what holds the
* search icon and the text off the border, and only this one child should escape it. The
* left margin cancels the flex gap as well, so the divider lands against the text the way
* the attached button did.
* A negative right margin rather than removing the control's padding: the padding is what
* holds the search icon and the text off the border, and only this one child should escape
* it. The gap to its LEFT is deliberately left alone -- cancelling that too welded the
* loading spinner to the divider whenever a field was both `loading` and `clearable`, which
* SearchResultsInput does, and the spinner is not part of this control.
*
* `html` because Mantine sets ActionIcon's height from `--ai-size` on its own single class;
* at equal specificity the winner is whichever stylesheet loaded last, which is not a thing
* to rely on.
* to rely on. `min-height` has to go with it: stretch cannot shrink a box below its own
* minimum, so leaving that at `--ai-size` would mean this rule only half-owned the height it
* claims to set -- true today only because the field happens to be the taller of the two.
*
* The corner radius needs no rule: the theme zeroes every `--mantine-radius-*`, so there are
* no rounded corners to leave panel-coloured wedges against the square field.
*/
html .wrolpi-searchbox-clear {
align-self: stretch;
height: auto;
margin-left: -8px;
margin-right: -8px;
min-height: unset;
margin-right: calc(-1 * var(--searchbox-inset));
border-left: 1px solid var(--border);
}