fix(ui-buttons): fix textAlign center on Buttons without icon#2539
Open
fix(ui-buttons): fix textAlign center on Buttons without icon#2539
Conversation
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>
|
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.
Summary
contentwrapper was changed fromdisplay: blocktodisplay: flex. As a flex container with a single shrunk-to-content child span,textAlign: centerno longer had anything to center — buttons without an icon stayed left-aligned. Buttons with an icon kept working because their extrachildrenLayoutwrapper haswidth: 100%and an explicitjustifyContent: center.justifyContent: textAlign === 'center' ? 'center' : 'flex-start'to thecontentflex container inpackages/ui-buttons/src/BaseButton/v2/styles.ts, mirroring the logic already used inchildrenLayout.Test Plan
ButtonwithtextAlign="center"anddisplay="block"(norenderIcon) — label should be horizontally centered.Buttonwith arenderIcon— label + icon should still be horizontally centered (no regression).ButtonwithtextAlign="start"(default) — label should remain left-aligned, both with and without an icon.pnpm run test:vitest ui-buttonspasses.Jira Reference
Fixes INSTUI-5015
🤖 Generated with Claude Code