Skip to content

fix(ui-buttons): fix textAlign center on Buttons without icon#2539

Merged
balzss merged 1 commit into
masterfrom
fix/button-text-align
May 7, 2026
Merged

fix(ui-buttons): fix textAlign center on Buttons without icon#2539
balzss merged 1 commit into
masterfrom
fix/button-text-align

Conversation

@balzss

@balzss balzss commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • In v11.7 the v2 BaseButton's content wrapper was changed from display: block to display: flex. As a flex container with a single shrunk-to-content child span, textAlign: center no longer had anything to center — buttons without an icon stayed left-aligned. Buttons with an icon kept working because their extra childrenLayout wrapper has width: 100% and an explicit justifyContent: center.
  • Fix: add justifyContent: textAlign === 'center' ? 'center' : 'flex-start' to the content flex container in packages/ui-buttons/src/BaseButton/v2/styles.ts, mirroring the logic already used in childrenLayout.

Test Plan

  • Render a Button with textAlign="center" and display="block" (no renderIcon) — label should be horizontally centered.
  • Render the same Button with a renderIcon — label + icon should still be horizontally centered (no regression).
  • Render a Button with textAlign="start" (default) — label should remain left-aligned, both with and without an icon.
  • pnpm run test:vitest ui-buttons passes.
  • Visual regression suite for Button passes.

Jira Reference

Fixes INSTUI-5015

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-05-07 14:47 UTC

The content wrapper changed from display:block to display:flex in the v2
button rewrite, which made textAlign:center ineffective on the shrunk
children span. Add justifyContent based on textAlign so text is centered
regardless of whether an icon is present.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@balzss balzss force-pushed the fix/button-text-align branch from 0b78ab5 to c62a499 Compare May 7, 2026 11:33
@balzss balzss requested review from HerrTopi and matyasf May 7, 2026 11:33
@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown

Visual regression report

No changes.

Status Count
Unchanged 32
Changed 0
New 0
Removed 0

📊 View full report

Baselines come from the visual-baselines branch. They refresh on every merge to master.

github-actions Bot pushed a commit that referenced this pull request May 7, 2026
…) 902825581c961a2b5089db3ba5b4865673ea610b
@balzss balzss merged commit b46ddb7 into master May 7, 2026
8 checks passed
@balzss balzss deleted the fix/button-text-align branch May 7, 2026 14:46
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.

3 participants