mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-05 14:19:56 -05:00
test: act on review — and one of the seven turned out to be undemonstrable
Six real fixes and one honest retraction.
The control is now a SIBLING of the heading inside a flex row, not a child of
it. Inside the `<h3>` it joined the heading's accessible name, so screen reader
heading navigation announced "Root CA Certificate Help". The row is what keeps
them on one line, and it is only rendered when there is something to sit beside,
so the markup for the other 46 call sites is unchanged.
`style` now lands on the wrapper. It used to reach the outer div; going through
Header put it on the inner heading, where a margin sets space INSIDE the wrapper
and only worked at all through margin collapse -- which stops the moment the
wrapper gains padding or a border. Status's "Drive Bandwidth" is the live case:
verified 16px on the block, 0 on the h2. Text properties still arrive, because
colour and text-align inherit; the `color` PROP stays on the heading.
A `<label>` only when `for_` names a field. Several call sites pass an
InfoHeader as the `label` prop of InputForm/ToggleForm, which wraps it in a
label of its own -- an unconditional one nested labels, which is invalid and
makes clicking the text ambiguous. Verified: zero `label label` on
/videos/settings, where "Video Resolutions" keeps its label and "Video File
Format" no longer has one.
The help controls carried `iconStyle: {margin: '0.5em'}`, which separated a
free-floating sibling and, inside the row, added to the gap on every side.
Zeroed; the row's gap is the spacing.
The browser test mounted a plain Button in an `after` slot rather than a real
HelpHeader, so the default icon chrome above was exactly what it could not see.
It mounts the real wrapper now. Two of my assertions were also too weak to
catch what they claimed: the gap was measured to `.wrolpi-header-after`, a flex
container whose own rect does not move when a child gains a margin, so it had to
measure the button; and the squeeze case used a title of ordinary words, which
simply wraps and never puts the row under pressure.
Renamed the suites -- "keeps the icon on its own line" read as the opposite of
the fix.
The retraction: `flex-shrink: 0` is declared but has NO test. Three attempts
could not find a width where removing it changes what is painted -- the row's
only other item is a heading, and its automatic minimum size absorbs the
pressure; the help control is an ActionIcon with a min-width it will not go
below either. The declaration stays as a statement of intent, with a comment
saying it is unproven, rather than a green test that does not discriminate.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c18fe84783
commit
fc0958369b
6 changed files with 174 additions and 43 deletions
|
|
@ -28,11 +28,14 @@ export interface HeaderProps extends Omit<React.HTMLAttributes<HTMLHeadingElemen
|
|||
*/
|
||||
color?: string;
|
||||
/**
|
||||
* Trailing content on the heading's own line — a help button, a count, a small
|
||||
* control. It goes inside the heading's flex row, which is the only place it can
|
||||
* sit beside the text: the wrapper is a block, so a sibling placed after it wraps
|
||||
* to the next line. That is exactly what happened to every help icon in the app
|
||||
* when these headings stopped being a bare `<h3>`.
|
||||
* Trailing content on the heading's row — a help button, a count, a small control.
|
||||
*
|
||||
* It is a SIBLING of the heading element inside a flex row, not a child of it: a
|
||||
* control inside an `<h3>` becomes part of the heading's accessible name, so screen
|
||||
* reader heading navigation announces "Root CA Certificate Help". The row is what
|
||||
* keeps the two on one line; a sibling placed after the block wrapper wraps instead,
|
||||
* which is what happened to every help icon in the app when these headings stopped
|
||||
* being a bare `<h3>`.
|
||||
*/
|
||||
after?: React.ReactNode;
|
||||
}
|
||||
|
|
@ -48,19 +51,39 @@ export function Header({
|
|||
as = 'h3', icon, subheader, dividing, color, after, className, style, children, ...props
|
||||
}: HeaderProps) {
|
||||
const Tag = as;
|
||||
return <div className={['wrolpi-header', dividing ? 'wrolpi-header-dividing' : '', className]
|
||||
.filter(Boolean).join(' ')}>
|
||||
<Tag
|
||||
className={`wrolpi-header-text wrolpi-header-${as}`}
|
||||
style={color ? {color: `var(--${color})`, ...style} : style}
|
||||
{...props}
|
||||
>
|
||||
{icon && (typeof icon === 'string'
|
||||
? <Icon name={icon} size='medium'/>
|
||||
: <Icon component={icon} size='medium'/>)}
|
||||
<span>{children}</span>
|
||||
{after && <span className='wrolpi-header-after'>{after}</span>}
|
||||
</Tag>
|
||||
const heading = <Tag
|
||||
className={`wrolpi-header-text wrolpi-header-${as}`}
|
||||
style={color ? {color: `var(--${color})`} : undefined}
|
||||
{...props}
|
||||
>
|
||||
{icon && (typeof icon === 'string'
|
||||
? <Icon name={icon} size='medium'/>
|
||||
: <Icon component={icon} size='medium'/>)}
|
||||
<span>{children}</span>
|
||||
</Tag>;
|
||||
|
||||
/*
|
||||
* `style` lands on the WRAPPER, because every layout use of it is about the header as a
|
||||
* block -- `marginBottom` on Status's "Drive Bandwidth", `marginTop` on the extension
|
||||
* page's steps. On the inner heading those set a margin inside the wrapper and depended
|
||||
* on margin collapse to have any effect at all, which stops the moment the wrapper gains
|
||||
* padding or a border. Text properties passed this way still reach the heading: `color`
|
||||
* and `text-align` inherit. A `color` PROP stays on the heading, since that is about the
|
||||
* text rather than the box.
|
||||
*/
|
||||
return <div
|
||||
className={['wrolpi-header', dividing ? 'wrolpi-header-dividing' : '', className]
|
||||
.filter(Boolean).join(' ')}
|
||||
style={style}
|
||||
>
|
||||
{/* The row exists only when there is something to sit beside; without it the
|
||||
markup for the other 46 call sites is unchanged. */}
|
||||
{after
|
||||
? <div className='wrolpi-header-row'>
|
||||
{heading}
|
||||
<span className='wrolpi-header-after'>{after}</span>
|
||||
</div>
|
||||
: heading}
|
||||
{subheader && <div className='wrolpi-header-sub'>{subheader}</div>}
|
||||
</div>
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue