[radio-button] Render content labels as a real label part (#376) - #378
Merged
Conversation
- A string :label must render as a real ::rb/label part carrying rc-radio-button-label + :label-class, the theme padding + :label-style, the label as its child, and an on-click (label clicks toggle — the pre-2.29 behaviour); hiccup labels wrap, absent labels render no part - RED: part/part's string shortcut returns the label verbatim, so no label part exists in the tree Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- part/part's string shortcut returns a string part-value verbatim, bypassing impl, theme and post-props. Since :top-level-arg? conflates the :label content arg with the part override, every string/hiccup :label rendered as a bare text node: no rc-radio-button-label element, no theme padding, :label-style/:label-class silently ignored, and no on-click — label clicks stopped toggling the radio - New part/content? predicate (string | number | hiccup); radio-button wraps content labels in the themed ::rb/label span (children), while map/fn part values keep their override semantics - The on-click now rides :attr (part/default only emits class/style/attr), restoring label-click toggling; the part structure declares the label's real :tag :span instead of :impl "empty" Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…trap theme - theme/re-com-meta already adds rc-radio-button-label automatically via part/css-class; keeping the literal produced a duplicated class once the label part actually rendered (#376) Co-Authored-By: Claude Fable 5 <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.
Closes #376.
What
Since the 2.29.x part migration,
radio-buttonrendered a string:labelas a bare text node: no label element, norc-radio-button-label, the theme'spadding-leftand the caller's:label-style/:label-classsilently ignored — and (unreported until now) noon-click, so clicking the label stopped toggling the radio.Root cause
Not the
:impl "empty"the issue originally blamed — it'spart/part's string shortcut: a string part-value is returned verbatim, bypassing the impl, the theme, andpost-props. Because:top-level-arg? trueconflates the:labelcontent argument with the:partsoverride mechanism,:label "text"(the universal case) takes the wholesale-replacement path. (Correction posted on the issue: the "component:stylelands on the input" observation was pre-existing parity, not a regression — pre-migration also mergedclass/style/attronto the input.)The fix
part/content?predicate (string | number | hiccup).radio-buttonwraps content labels in the themed::rb/labelspan with the content as:children— the theme (rc-radio-button-labelvia the automatic part class,padding-left,:label-style/:label-class) and the click handler all apply again. Map/fn part values keep their override semantics.on-clickrides:attr(wherepart/defaultactually emits handlers), restoring label-click toggling; the part structure declares the label's real:tag :spaninstead of:impl "empty"."rc-radio-button-label"literal is dropped —theme/re-com-metaalready adds it automatically, and keeping both produced a duplicated class once the label element actually rendered.Testing
test/re_com/radio_button_test.cljs: renders the component fn and walks the hiccup for the label part's props — asserts the element exists, the classes/styles/children/on-click all land, hiccup labels wrap, absent labels emit no part. RED on master (no label part in the tree), GREEN with the fix. Suite: 69 tests / 257 assertions, 0 failures.:label-style) and downstream in app usage against this branch via a:local/rootoverride changes render with correct spacing and clickable labels..rc-radio-button-wrapper {gap: 8px}) should remove them when bumping, or spacing doubles.Sibling issue filed: #377 —
checkboxhas the same latent string-label bypass (invisible because its theme spaces via wrapper gap), fixable with the samepart/content?pattern.🤖 Generated with Claude Code