Skip to content

fix(ui): collapse Icon line-box to fix baseline misalignment#1789

Merged
edda merged 2 commits into
mainfrom
edda/fix-icon-baseline-alignment
Jun 23, 2026
Merged

fix(ui): collapse Icon line-box to fix baseline misalignment#1789
edda merged 2 commits into
mainfrom
edda/fix-icon-baseline-alignment

Conversation

@edda

@edda edda commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a baseline-alignment bug where Icon rendered with descender space below the SVG, shifting icons above the visual centerline of flex layouts. Collapses the icon's containment chain to its content via inline-flex + leading-none, and applies the same treatment to PopupMenu, ComboBox, and Select — components that visibly relied on the prior (coincidental) alignment.

Changes Made

  • Icon (Icon.component.tsx): plain-icon wrapper <span>, buttonIconStyles, and anchorIconStyles now use inline-flex + leading-none so the wrapper hugs the SVG.
  • PopupMenu (PopupMenu.component.tsx):
    • Outer HeadlessMenu wrapper switched to inline-flex.
    • Default toggle gets inline-flex items-center leading-none.
    • Custom toggles passed via <PopupMenu.Toggle> get the same alignment via shared baseToggleStyles applied in PopupMenuToggle.
    • Drive-by: fixed incomplete utility class jn:h-jn:h-px on PopupMenuSectionSeparator (matches Divider / SelectDivider convention; pre-existing typo).
  • ComboBox (ComboBox.component.tsx):
    • Toggle button: added inline-flex items-center justify-end leading-none so the chevron is centered vertically inside the h-textinput toggle.
    • Valid/invalid icon container: replaced magic-number top-[.4rem] with top-1/2 + translate-y-[-50%] so positioning is independent of icon height / line-height.
    • centeredIconStyles (error/loading icon): added inline-flex leading-none so the translate-50% centering operates on the SVG box.
  • Select (Select.component.tsx):
    • centeredIconStyles: same treatment as ComboBox.
    • Outer flex span around chevron/validation icons: added items-center; bare wrapper span around the chevron now uses inline-flex leading-none.
  • PageHeader (PageHeader.stories.tsx): new WithThemeToggleAndUserMenu story as a visual-regression target for icon alignment in a flex row.

Related Issues

Screenshots (if applicable)

Before:
Screenshot 2026-06-22 at 18 20 53

After:
Screenshot 2026-06-22 at 18 19 08

Testing Instructions

  1. pnpm i
  2. pnpm --filter @cloudoperators/juno-ui-components test — confirm Icon, PopupMenu, ComboBox, and Select tests pass.
  3. cd packages/ui-components && pnpm storybook — then visually inspect:
    • Layout/PageHeader → With Theme Toggle And User Menu (new story; both icons should be centered in the flex row).
    • Components/PopupMenu stories: default toggle, custom toggles, and items with icons.
    • Forms/ComboBox stories: default, valid, invalid, loading, error states.
    • Forms/Select stories: default, valid, invalid, loading, error states.
    • Components/Icon button and anchor variants.

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. (Added Storybook story for visual regression; no new unit tests since this is a CSS-only behavioral change.)
  • New and existing unit tests pass locally with my changes. (170 tests across Icon, PopupMenu, ComboBox, Select.)
  • 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.

…n alignment

The Icon component wrapped its SVG in containers that inherited the
surrounding line-height, leaving descender space below the SVG and
shifting icons above the visual centerline in flex layouts. This fix
collapses every container in the icon containment chain to its content
(via `inline-flex` + `leading-none`) so `align-items: center` centers
the actual icon, not a line-height-padded box.

Follow-up fixes in components that visibly relied on the prior behavior:

- PopupMenu: collapse outer wrapper, default toggle, and base toggle
  styles so default and custom toggles both align correctly.
- ComboBox: switch toggle button and validation/loading icon containers
  to explicit flex centering and `top-1/2 + translate-y-[-50%]` so
  positioning is independent of font-size, line-height, and icon size.
- Select: same treatment for chevron span and centered (error/loading)
  icon container.

Also fixed an unrelated incomplete utility class `jn:h-` in
`PopupMenuSectionSeparator` (now `jn:h-px`, matching Divider).

Added a PageHeader story `WithThemeToggleAndUserMenu` as a visual
regression target for the alignment fix.

Refs #1788

Signed-off-by: Esther Schmitz <esther.schmitz@sap.com>
Copilot AI review requested due to automatic review settings June 22, 2026 15:42
@edda edda requested review from a team and franzheidl as code owners June 22, 2026 15:42
@changeset-bot

changeset-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c5edd23

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 22, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-06-23 07:36 UTC

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 addresses baseline/line-box-driven icon misalignment in flex layouts by collapsing icon wrappers (and a few consuming components) to the SVG/content box using Tailwind utilities like inline-flex and leading-none, plus follow-up centering fixes where prior alignment depended on inherited line-height.

Changes:

  • Collapse Icon wrapper line-boxes (plain/anchor/button variants) so SVGs don’t carry descender space.
  • Update PopupMenu, ComboBox, and Select to use flex-based centering and remove line-height-dependent positioning.
  • Add a PageHeader Storybook story as a visual regression target; add a changeset for the patch release.

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/Icon/Icon.component.tsx Collapses icon wrappers with inline-flex + leading-none to eliminate descender-space baseline issues.
packages/ui-components/src/components/PopupMenu/PopupMenu.component.tsx Applies shared toggle alignment styles and updates wrapper display; fixes separator height utility.
packages/ui-components/src/components/ComboBox/ComboBox.component.tsx Centers toggle/validation icons via flex + top-1/2/translate rather than magic offsets.
packages/ui-components/src/components/Select/Select.component.tsx Aligns chevron/validation icons and collapses centered icon wrapper line-box.
packages/ui-components/src/components/PageHeader/PageHeader.stories.tsx Adds a story to visually verify icon alignment in a centered flex row.
.changeset/icon-baseline-alignment.md Publishes a patch changeset for the UI components package.

Comment thread packages/ui-components/src/components/Icon/Icon.component.tsx Outdated
@edda edda self-assigned this Jun 22, 2026
- PopupMenuToggle: replace `${disabled && ...}` with ternary to avoid
  emitting a literal "false" class on enabled toggles
- Icon plain-icon path: drop ref from span wrapper so forwardRef type
  (HTMLAnchorElement | HTMLButtonElement) remains accurate; the plain
  icon path never forwarded a ref before this PR
- Reformat plain-icon return with prettier

Signed-off-by: Esther Schmitz <esther.schmitz@sap.com>
@edda edda merged commit 72b2ba6 into main Jun 23, 2026
26 checks passed
@edda edda deleted the edda/fix-icon-baseline-alignment branch June 23, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug](ui): Icon renders with descender space below SVG, misaligning in flex layouts

4 participants