Skip to content

fix(ui): pass the correct BuildContext to onReactionPicked (#1234)#2823

Open
w830207 wants to merge 2 commits into
GetStream:masterfrom
w830207:master
Open

fix(ui): pass the correct BuildContext to onReactionPicked (#1234)#2823
w830207 wants to merge 2 commits into
GetStream:masterfrom
w830207:master

Conversation

@w830207

@w830207 w830207 commented Jul 17, 2026

Copy link
Copy Markdown
  • fix(ui): pass the correct BuildContext to onReactionPicked

Pass the appropriate BuildContext to the onReactionPicked callback so navigation uses the correct context.

  • Update tests and usages to match the new signature.

Submit a pull request

Linear: FLU-

Github Issue: #

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

Description of the pull request

This PR fixes an issue where onReactionPicked could receive an incorrect BuildContext.

When the reaction picker is used within nested navigators, using the wrong BuildContext may cause navigation operations (such as Navigator.pop) to target the wrong navigator, resulting in the parent page being closed unexpectedly.

This change passes the correct BuildContext to onReactionPicked, ensuring navigation is performed on the intended navigator.

Changes included:

  • Pass the correct BuildContext to onReactionPicked.
  • Update the callback signature to include BuildContext.
  • Update all tests and usages to match the new callback signature.

Screenshots / Videos

Before After
img img

Summary by CodeRabbit

  • Bug Fixes
    • Fixed reaction selection so the correct screen context is used when closing reaction modals/pickers, preventing unexpected parent route pops in nested navigator setups.
  • Refactor
    • Updated the reaction picker callback contract to provide the active BuildContext alongside the selected reaction, ensuring consistent behavior across platforms.
  • Tests
    • Updated reaction picker tests to match the new callback signature and verified both interaction behavior and rendered states.

…am#1234)

* fix(ui): pass the correct BuildContext to `onReactionPicked`

Pass the appropriate `BuildContext` to the `onReactionPicked`
callback so navigation uses the correct context.

* Update tests and usages to match the new signature.
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0d2efabf-538b-4a41-886c-8ae23217520b

📥 Commits

Reviewing files that changed from the base of the PR and between 0f57a73 and 15a387a.

📒 Files selected for processing (1)
  • packages/stream_chat_flutter/CHANGELOG.md

📝 Walkthrough

Walkthrough

The reaction picker callback now receives a BuildContext alongside the selected Reaction. Modal integrations use that context when dismissing, and picker tests and the changelog reflect the updated behavior.

Changes

Reaction picker context callback

Layer / File(s) Summary
Update reaction picker callback contract
packages/stream_chat_flutter/lib/src/reactions/picker/reaction_picker.dart
The picker replaces the old callback typedef with a two-argument callback and passes context for existing and newly added reactions.
Update modal callback integrations
packages/stream_chat_flutter/lib/src/message_modal/message_actions_modal.dart, packages/stream_chat_flutter/lib/src/message_widget/stream_message_item.dart
Modal callbacks accept the provided context and use it when popping the reaction selection modal.
Update callback tests and changelog
packages/stream_chat_flutter/test/src/reactions/picker/reaction_picker_test.dart, packages/stream_chat_flutter/CHANGELOG.md
Picker tests adopt the updated callback signature, and the changelog records the nested-navigator context correction.

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

Suggested reviewers: xsahil03x

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: passing the correct BuildContext to onReactionPicked.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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_chat_flutter/lib/src/reactions/picker/reaction_picker.dart (1)

35-35: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Specify the void return type for strict typing.

The previous ValueSetter<Reaction> typedef inherently enforced a void return type. Changing the field to Function(Reaction, BuildContext)? makes the return type dynamic. It is recommended to explicitly declare the void return type for stricter type safety.

♻️ Proposed refactor
-  final Function(Reaction, BuildContext)? onReactionPicked;
+  final void Function(Reaction, BuildContext)? onReactionPicked;
🤖 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_chat_flutter/lib/src/reactions/picker/reaction_picker.dart`
at line 35, Update the onReactionPicked callback type in ReactionPicker to
explicitly return void while retaining its Reaction and BuildContext parameters
and optionality, restoring the strict return-type contract previously provided
by ValueSetter<Reaction>.
🤖 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_chat_flutter/lib/src/reactions/picker/reaction_picker.dart`:
- Line 35: Update the onReactionPicked callback type in ReactionPicker to
explicitly return void while retaining its Reaction and BuildContext parameters
and optionality, restoring the strict return-type contract previously provided
by ValueSetter<Reaction>.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c4648df1-b6f5-4a14-82cd-81da836ee0ab

📥 Commits

Reviewing files that changed from the base of the PR and between 5f7f33c and 0f57a73.

📒 Files selected for processing (4)
  • packages/stream_chat_flutter/lib/src/message_modal/message_actions_modal.dart
  • packages/stream_chat_flutter/lib/src/message_widget/stream_message_item.dart
  • packages/stream_chat_flutter/lib/src/reactions/picker/reaction_picker.dart
  • packages/stream_chat_flutter/test/src/reactions/picker/reaction_picker_test.dart

final Message message;

/// {@macro onReactionPicked}
final OnReactionPicked? onReactionPicked;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a breaking change for anybody using the ReactionPicker directly. If the context is really needed we should make a new method and deprecate the old one.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the feedback. That's a great suggestion.

I can make this change. Do you have any recommendations for the new method name?

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.

2 participants