fix: keep wrapping item labels in line with their fields (#2048) - #2072
Open
clinnygee wants to merge 1 commit into
Open
fix: keep wrapping item labels in line with their fields (#2048)#2072clinnygee wants to merge 1 commit into
clinnygee wants to merge 1 commit into
Conversation
A question label that wrapped onto multiple lines was rendered below its field instead of beside it. Two separate causes: 1. The label text sits in a `display: inline-flex` box, which takes its baseline from its first flex item - usually the empty prefix span. Once the text wrapped, that baseline sat ~15px below the surrounding line box's baseline, pushing the whole label down. The box now aligns to the top of its line box instead. 2. Labels supplied as rendering-xhtml are wrapped in a `<p>`, whose block margins added a further offset. Question labels now trim the outer paragraph margins; display items keep theirs, since they are standalone blocks of prose rather than a single run of text. Measured from the top of the row, plain, xhtml and string labels all go from 25px to 10px - the same offset a single-line label already had. Adds a WrappingItemLabels story whose play function asserts the first line of label text starts at the top of its row. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2048.
Problem
In the "Absolute cardiovascular disease risk calculation" section of the Aboriginal and Torres Strait Islander Health Check, the question "Do you have access to the Aus CVD Risk-i application from your clinical system?" rendered well below its Yes/No radios rather than beside them.
This was not specific to that question — any item label long enough to wrap onto a second line was affected, for plain text,
rendering-xhtmlandrendering-markdownalike.Causes
Two independent issues, both in
ItemLabel:Inline-flex baseline. The label text sits in a
display: inline-flexbox. An inline-flex box takes its baseline from its first flex item — here the usually-empty prefix span. Once the text wrapped, that baseline sat ~15px below the surrounding line box's baseline, pushing the whole label down. The box now aligns to the top of its line box.XHTML paragraph margins. Labels supplied as
rendering-xhtmlare wrapped in a<p>, whosemargin-block-startadded a further 14px. Question labels now trim their outer paragraph margins. Display items keep theirs, since they are standalone blocks of prose rather than a single run of label text.Group headings were never affected — their
Typographyis already a flex container, which blockifies the inner box and removes it from the line box entirely. Grid groups are also unaffected, since their table cells centre vertically;GridRow/GridTableare left alone.Result
Measured from the top of the row to the first line of label text:
10px is the offset a single-line label already had (
ItemLabel's 4px nudge plus the line's half-leading), so wrapping labels now sit exactly where non-wrapping ones do.Verified by rendering the real assembled 715 questionnaire's CVD section: the question now lines up with its radios, matching the plain-text question directly above it.
Testing
WrappingItemLabelsstory underSDC/9.1.1 Rendering > Text Appearance, covering plain, xhtml and string wrapping labels. Its play function asserts the first line of label text starts at the top of its row; it passes with the fix and fails (25px > 12px threshold) without it.tsc) and rootnpm run lintpass with no errors.🤖 Generated with Claude Code