Skip to content

fix(ui): fix and improve Checkbox and Radio layout, markup, and props routing#1772

Open
franzheidl wants to merge 5 commits into
mainfrom
franz-fix-checkbox—radio-1753-1754

Hidden character warning

The head ref may contain hidden characters: "franz-fix-checkbox\u2014radio-1753-1754"
Open

fix(ui): fix and improve Checkbox and Radio layout, markup, and props routing#1772
franzheidl wants to merge 5 commits into
mainfrom
franz-fix-checkbox—radio-1753-1754

Conversation

@franzheidl

@franzheidl franzheidl commented Jun 17, 2026

Copy link
Copy Markdown
Member

Summary

Addresses layout, markup, and API issues in the Checkbox and Radio components.

Changes Made

Layout & alignment

The native <input> element in both Checkbox and Radio components was in normal flow inside the mock wrapper <div>, causing the wrapper to exceed the intended 16x16 size due to browser-implied inline-block rendering and line-height. This resulted in the components appearing visually shifted upward in items-center flex contexts (e.g. DataGrid rows).

  • Native <input> is now positioned absolute inset-0, making it an overlay on the mock with the same dimensions (even if we change them at some point in the future), but not influencing/disturbing element flow
  • leading-0 added to the outer container <div> to eliminate inherited line-height from parent contexts, which was the remaining source of implicit height

Props routing

Arbitrary ...props were spread onto the decorative mock div (div.juno-checkbox / div.juno-radio) rather than the native <input> element before. Attributes like aria-label, aria-describedby, and data-* therefore landed on the wrong element – semantically incorrect and broken for accessibility tooling. Arbitrary props are now re-routed to the actual <input> element:

  • ...props and className are now forwarded to the native <input> element
  • CheckboxProps updated from HTMLAttributes<HTMLDivElement> to InputHTMLAttributes<HTMLInputElement>
  • RadioProps updated from Omit<HTMLAttributes<HTMLDivElement>, "onChange"> to Omit<InputHTMLAttributes<HTMLInputElement>, "onChange">, preserving the custom onChange signature
  • New wrapperClassName prop introduced on both components for styling the outer container, consistent with the pattern used across the library (TextInput, Switch, Select, Textarea, ComboBox, etc.)

Additional fixes

  • useId was called inside a nested helper function before, in effect violating Rules of Hooks , the useId call now lives in an unconditional top-level call in both Checkbox and Radio (this is a problem spread across our components)
  • Copy-paste bug in RadioGroup corrected: inner options container was incorrectly classed juno-checkbox-group-options instead of juno-radio-group-options, this is fixed now
  • Explanatory comments added to style constants in both components to document the non-obvious CSS layout decisions

Tests

Existing tests updated to reflect the new className forwarding target; new tests added for wrapperClassName, aria-label forwarding, and arbitrary prop forwarding.

Related Issues

Fixes #1714, closes #1753, closes #1754.

Screenshots

Checkbox Alignment Before:

Bildschirmfoto 2026-06-17 um 12 11 39

Checkbox Alignment After:

Bildschirmfoto 2026-06-17 um 12 10 30

Testing Instructions

  1. pnpm i
  2. pnpm run test Checkbox CheckboxGroup Radio RadioGroup

Checklist

  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have made corresponding changes to the documentation (if applicable).
  • My changes generate no new warnings or errors.
  • I have created a changeset for my changes.

PR Manifesto

Review the PR Manifesto for best practises.

* Position native input absolutely within the mock wrapper to eliminate implied height inflation
* Make sure input has the exact same dimensions as the mock wrapper
* Route ...props and className to the native input
* Update HTML attributes type accordingly
* Introduce wrapperClassName for outer container styling, consistent with other components
* Update and add tests accordingly

Signed-off-by: Franz Heidl <f.heidl@sap.com>
* Position native input absolutely within the mock wrapper to eliminate implied height inflation
* Make sure input has the exact same dimensions as the mock wrapper
* Route ...props and className to the native input
* Update HTML attributes type accordingly
* Introduce wrapperClassName for outer container styling, consistent with other components
* Fix copy-paste bug: correct juno-checkbox-group-options to juno-radio-group-options in RadioGroup
* Update and add tests accordingly

Signed-off-by: Franz Heidl <f.heidl@sap.com>
* Remove jn:leading-0 from labelStyles in Checkbox and Radio as it was
  breaking the required marker position and label alignment
* Add jn:leading-[0] to the outer container div instead, which is the
  correct place to suppress inherited line-height from parent contexts
* Add explanatory comments to style constants in both components to
  document the non-obvious CSS layout decisions

Signed-off-by: Franz Heidl <f.heidl@sap.com>
@changeset-bot

changeset-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 30f132a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@cloudoperators/juno-ui-components Patch
@cloudoperators/juno-app-carbon Patch
@cloudoperators/juno-app-doop Patch
@cloudoperators/juno-app-example Patch
@cloudoperators/juno-app-greenhouse Patch
@cloudoperators/juno-app-heureka Patch
@cloudoperators/juno-app-supernova Patch
@cloudoperators/juno-app-template Patch
@cloudoperators/juno-messages-provider Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

🚀 View preview at
https://cloudoperators.github.io/juno/pr-preview/pr-1772/

Built to branch gh-pages at 2026-06-17 10:23 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

- use plain strings for classNames where possible

Signed-off-by: Franz Heidl <f.heidl@sap.com>
@franzheidl franzheidl added the ui-components All tasks related to juno-ui-components library label Jun 17, 2026
Signed-off-by: Franz Heidl <f.heidl@sap.com>
@franzheidl franzheidl marked this pull request as ready for review June 17, 2026 10:33
Copilot AI review requested due to automatic review settings June 17, 2026 10:33
@franzheidl franzheidl requested a review from a team as a code owner June 17, 2026 10:33
@franzheidl franzheidl requested review from TilmanHaupt and edda June 17, 2026 10:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Checkbox and Radio components in @cloudoperators/juno-ui-components to correct vertical alignment issues, improve semantic markup by routing props to the native <input>, and align the public API with a new wrapperClassName prop. It also fixes a RadioGroup class name typo and updates/adds tests to reflect the new props routing behavior.

Changes:

  • Fix layout/alignment by overlaying the native <input> (absolute inset-0) and applying leading-0 to the outer container to avoid inherited line-height inflating height.
  • Route ...props and className to the native <input>; introduce wrapperClassName for styling the mock wrapper; update prop types accordingly.
  • Fix RadioGroup option container class name and update/add tests + add a changeset.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/ui-components/src/components/Checkbox/Checkbox.component.tsx Updates markup/layout and routes props to the native checkbox input; adds wrapperClassName.
packages/ui-components/src/components/Checkbox/Checkbox.test.tsx Updates tests for className/prop forwarding to the input and adds wrapperClassName coverage.
packages/ui-components/src/components/Radio/Radio.component.tsx Updates markup/layout and routes props to the native radio input; adds wrapperClassName.
packages/ui-components/src/components/Radio/Radio.test.tsx Updates tests for className/prop forwarding to the input and adds wrapperClassName/ARIA coverage.
packages/ui-components/src/components/RadioGroup/RadioGroup.component.tsx Fixes a copy/paste class name (juno-checkbox-group-optionsjuno-radio-group-options).
.changeset/little-shoes-tan.md Adds a patch changeset for the UI-components package.

Comment thread packages/ui-components/src/components/Radio/Radio.component.tsx

@TilmanHaupt TilmanHaupt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good.

@franzheidl franzheidl self-assigned this Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ui-components All tasks related to juno-ui-components library

Projects

Status: New

3 participants