fix(Banner): center a title-only banner whose only control is the collapse toggle - #5485
fix(Banner): center a title-only banner whose only control is the collapse toggle#5485freddymeta wants to merge 1 commit into
Conversation
…lapse toggle `isSingleLine` drives the header's vertical centering and counted `endContent` and the dismiss button, but not the collapse toggle. A collapsible title-only banner therefore kept `align-items: flex-start` while the same banner with a dismiss button centered — its icon and title sat 4px above the 28px toggle beside them. The toggle is the same control in the same row, so it counts.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsBanner (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
|
Folding this into #5483 — it is the same file and the same read, and two PRs on one component in one afternoon is more review surface than the change deserves. The commit is unchanged there ( |
The bug
Bannercenters its header vertically when the banner is one line of text with controls beside it — otherwise a 28px ghost button next to a 20px title reads as hanging. That is whatheaderCenteredis for, and its comment says so: "When there's only a title (no description) and actions, center everything vertically."But the test that drives it counts only two of the three things that can appear in the actions row:
The collapse toggle is missing. So two banners that render the same shape — a title, and one 28px icon-only ghost Button in the end area — align differently:
In the second, the icon and title sit 4px above the toggle they are level with.
showEndAreaon the line above already countshasToggle; onlyhasActionsdoes not.The fix
One term.
hasToggleis already computed two lines up, and is itselfisCollapsible && hasChildren, so acollapsible={false}banner and a banner with no children are untouched.Verification
pnpm exec vitest run packages/core/src/Banner— 56 passed (52 existing + 4 added under a newsingle-line centeringdescribe, covering all four combinations: dismiss-only, toggle-only, described-with-toggle, and no controls).Negative control: reverting the one-term change and re-running fails exactly one test — "centers a title-only banner whose only control is the collapse toggle" — and the other 55 stay green. So the new test really is watching this behaviour, and the change moves nothing else.
Found while bringing an internal EPS theme onto the real
Banner(context in #5417 / #5483): the theme had to reproduce this centering with its own CSS rule to match, which is how the asymmetry surfaced.