Skip to content

fix(ui): StreamButton icons picking up host app's ElevatedButtonThemeData.iconColor - #129

Merged
xsahil03x merged 2 commits into
mainfrom
fix/2786_streambutton_icon_color
Jul 13, 2026
Merged

fix(ui): StreamButton icons picking up host app's ElevatedButtonThemeData.iconColor#129
xsahil03x merged 2 commits into
mainfrom
fix/2786_streambutton_icon_color

Conversation

@xsahil03x

@xsahil03x xsahil03x commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

  • DefaultStreamButton now sets iconColor alongside foregroundColor on its widget-level ButtonStyle, closing the leak where a host app's ElevatedButtonThemeData.iconColor wins over StreamButton's own foreground via Flutter's ButtonStyleButton.effectiveIconColor resolution (widget.iconColor ?? theme.iconColor ?? widget.foregroundColor ?? …).
  • Added a regression test in stream_button_test.dart that pumps a StreamButton.icon with a host ElevatedButtonThemeData(iconColor: …) and asserts the icon does not paint the leaked host color.
  • Removed the dev-only stream_button_vs_icon_button_semantics_test.dart (print-only, no assertions).

Fixes GetStream/stream-chat-flutter#2786

Test plan

  • flutter test test/components/buttons/stream_button_test.dart — all 7 tests pass.
  • Verified test is load-bearing: reverting the one-liner fix causes the new test to fail.
  • Golden tests pass after regeneration (AA-only diffs; CI goldens left for CI to write).

Summary by CodeRabbit

  • Bug Fixes

    • Fixed StreamButton icons so they use the button’s configured foreground color instead of inheriting the host app’s button icon theme.
  • Tests

    • Added regression coverage to verify host button themes do not override StreamButton icon colors.
    • Removed outdated button color and semantics test coverage.

xsahil03x and others added 2 commits July 13, 2026 13:24
…Data.iconColor

Set `iconColor` alongside `foregroundColor` on the widget-level `ButtonStyle`
so a host-app `ElevatedButtonThemeData.iconColor` cannot win over StreamButton's
foreground via Flutter's `ButtonStyleButton.effectiveIconColor` resolution
(which prefers `theme.iconColor` over `widget.foregroundColor`).

Fixes GetStream/stream-chat-flutter#2786

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The file only pretty-printed SemanticsData for eyeball comparison against a
Material `IconButton`; it never asserted anything, so it doesn't guard behavior.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@xsahil03x
xsahil03x requested a review from a team as a code owner July 13, 2026 11:25
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

DefaultStreamButton now explicitly applies its resolved foreground color to icons. Tests cover isolation from host ElevatedButtonThemeData.iconColor, while two older button test files were removed and the changelog records the fix.

Changes

StreamButton icon color fix

Layer / File(s) Summary
Apply resolved icon color
packages/stream_core_flutter/lib/src/components/buttons/stream_button.dart, packages/stream_core_flutter/CHANGELOG.md
DefaultStreamButton assigns effectiveForegroundColor to ButtonStyle.iconColor; the changelog documents the upcoming fix.
Verify host theme isolation
packages/stream_core_flutter/test/components/buttons/stream_button_test.dart
The test theme helper accepts custom stream and elevated-button themes, and a regression test verifies that a host iconColor does not determine StreamButton icon color.

The color-resolution test and semantics comparison test files were removed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • GetStream/stream-chat-flutter 2786 — Concerns light-mode composer and attachment-picker icons using incorrect StreamButton colors.

Suggested reviewers: renefloor

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the main fix and affected StreamButton icon-color behavior.
Description check ✅ Passed The description covers the fix and test plan, but omits the template's CLA checklist and screenshots section.
Linked Issues check ✅ Passed The iconColor fix and regression test address issue #2786's light-mode icon leak requirement.
Out of Scope Changes check ✅ Passed The changes stay focused on StreamButton icon coloring and related tests, with no unrelated feature work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/2786_streambutton_icon_color

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.53%. Comparing base (e999d12) to head (939b431).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #129      +/-   ##
==========================================
- Coverage   45.80%   44.53%   -1.28%     
==========================================
  Files         178      178              
  Lines        7243     7243              
==========================================
- Hits         3318     3226      -92     
- Misses       3925     4017      +92     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/stream_core_flutter/test/components/buttons/stream_button_test.dart (1)

164-192: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Strengthen the regression test with a positive assertion on the expected icon color.

The current expect(capturedIconColor, isNot(hostIconColor)) is a negative-only check. If capturedIconColor were null (e.g., the Builder closure didn't execute or IconTheme wasn't resolved), null != hostIconColor is true and the test would pass silently. Asserting the actual expected foreground color would both guard against null and verify the icon uses the correct resolved color, not merely "not the host color."

♻️ Suggested addition: also assert the expected foreground color
       await tester.pumpAndSettle();
 
-      expect(capturedIconColor, isNot(hostIconColor));
+      expect(capturedIconColor, isNotNull);
+      expect(capturedIconColor, isNot(hostIconColor));
+
+      // Verify the icon uses StreamButton's resolved foreground color,
+      // not just "something other than the host color."
+      final button = tester.widget<ElevatedButton>(find.byType(ElevatedButton));
+      final resolvedIconColor = button.style?.iconColor?.resolve({});
+      expect(capturedIconColor, resolvedIconColor);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/stream_core_flutter/test/components/buttons/stream_button_test.dart`
around lines 164 - 192, Strengthen the assertion in the test “host-app
ElevatedButtonThemeData.iconColor does not leak into StreamButton icons” by
additionally verifying that capturedIconColor equals the expected resolved
StreamButton foreground color. Keep the existing host-color inequality check if
useful, and ensure the positive assertion rejects null while confirming the
intended icon color.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@packages/stream_core_flutter/test/components/buttons/stream_button_test.dart`:
- Around line 164-192: Strengthen the assertion in the test “host-app
ElevatedButtonThemeData.iconColor does not leak into StreamButton icons” by
additionally verifying that capturedIconColor equals the expected resolved
StreamButton foreground color. Keep the existing host-color inequality check if
useful, and ensure the positive assertion rejects null while confirming the
intended icon color.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e3beb0fe-14d1-45c1-ad0a-8f3a0fa324f7

📥 Commits

Reviewing files that changed from the base of the PR and between e999d12 and 939b431.

📒 Files selected for processing (5)
  • packages/stream_core_flutter/CHANGELOG.md
  • packages/stream_core_flutter/lib/src/components/buttons/stream_button.dart
  • packages/stream_core_flutter/test/components/buttons/stream_button_color_resolution_test.dart
  • packages/stream_core_flutter/test/components/buttons/stream_button_test.dart
  • packages/stream_core_flutter/test/components/buttons/stream_button_vs_icon_button_semantics_test.dart
💤 Files with no reviewable changes (2)
  • packages/stream_core_flutter/test/components/buttons/stream_button_color_resolution_test.dart
  • packages/stream_core_flutter/test/components/buttons/stream_button_vs_icon_button_semantics_test.dart

@xsahil03x
xsahil03x merged commit a207edb into main Jul 13, 2026
14 checks passed
@xsahil03x
xsahil03x deleted the fix/2786_streambutton_icon_color branch July 13, 2026 11:50
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.

v10: composer / attachment-picker icons render white (invisible) in light mode despite a light StreamColorScheme

2 participants