Skip to content

fix: keep icon button content centered - #5014

Open
vivekjm wants to merge 3 commits into
callstack:mainfrom
vivekjm:fix-iconbutton-centered-content
Open

vivekjm wants to merge 3 commits into
callstack:mainfrom
vivekjm:fix-iconbutton-centered-content

Conversation

@vivekjm

@vivekjm vivekjm commented Jun 28, 2026

Copy link
Copy Markdown

Summary

Fixes #4829.

This changes the IconButton ripple content from flexGrow: 1 to flex: 1 so the pressable content reliably fills the fixed-size container before centering the icon. That keeps the icon centered when callers add custom container styles such as a background color.

Test plan

  • yarn test src/components/__tests__/IconButton.test.tsx --runInBand
  • yarn lint
  • yarn typecheck
  • yarn test -u updated snapshots affected by the shared IconButton style. The full run otherwise passes except src/babel/__tests__/index.js, which cannot start because this checkout does not have lib/mappings.json generated and yarn generate-mappings points to a missing scripts/generate-mappings.ts file.

@Doberjohn

Copy link
Copy Markdown
Collaborator

Thanks for this fix, @vivekjm. We'd like to merge it before the IconButton rewrite in #5103. Could you bring the branch up to date with main? Most of the conflicts are snapshots, which yarn test -u regenerates. On main, components no longer pass test IDs down by default (#5088, #5099), so the new test may need to find the button by role instead. Once it's updated I'll approve the CI run and review it.

This branch has not been deployed

No deployments
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.

Icon in IconButton not centered and cannot be centered

2 participants