Skip to content

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

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

fix(ui): pass the correct BuildContext to onReactionPicked (#1234)#2823
w830207 wants to merge 8 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 picker and message reaction flows to dismiss using the correct screen context in nested navigator setups.
  • New Features
    • Added onReactionSelected(BuildContext, Reaction) to the reaction picker for context-aware handling.
    • Updated reaction picker/modal wiring so the new callback is invoked on both selecting and creating reactions.
  • Deprecation
    • Deprecated onReactionPicked(Reaction) in favor of onReactionSelected.
  • Tests
    • Updated picker and golden tests to use the new callback signature and assertions.

…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

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bed22ec7-66c5-472d-adca-8111ab4fb5ff

📥 Commits

Reviewing files that changed from the base of the PR and between 12a3c30 and 2e24f23.

📒 Files selected for processing (1)
  • packages/stream_chat_flutter/CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/stream_chat_flutter/CHANGELOG.md

📝 Walkthrough

Walkthrough

The reaction picker adds a context-aware callback while retaining the deprecated callback. Modal integrations use the provided 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 adds a two-argument callback, retains the deprecated callback, and invokes both callbacks 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 callback update.

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 captures the core UI fix: providing the correct BuildContext to the reaction callback, even though the implementation renames/widens the callback.
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?

w830207 added 2 commits July 25, 2026 22:30
* Deprecate `onReactionPicked` in favor of `onReactionSelected` to provide `BuildContext` for better navigation handling.
* Update `StreamMessageItem` and `MessageActionsModal` to use the new `onReactionSelected` callback.
* Add unit tests to verify `onReactionSelected` behavior and ensure backward compatibility with `onReactionPicked`.

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/stream_chat_flutter/lib/src/reactions/picker/reaction_picker.dart (1)

6-9: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Restore the legacy callback signature.

OnReactionPicked previously accepted (BuildContext, Reaction), so changing it to ValueSetter<Reaction> makes existing direct picker consumers fail to compile. Keep the deprecated typedef and its invocations source-compatible; use onReactionSelected as the new context-aware API. This is the breaking API concern previously raised.

🤖 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`
around lines 6 - 9, Restore OnReactionPicked to the legacy callback signature
accepting BuildContext and Reaction, and retain it as a deprecated typedef for
source compatibility. Update direct picker invocations to pass both arguments,
while keeping onReactionSelected as the new context-aware API.
🧹 Nitpick comments (1)
packages/stream_chat_flutter/test/src/reactions/picker/reaction_picker_test.dart (1)

91-113: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test the nested-navigator behavior.

This test ignores the supplied BuildContext, so it passes even if the picker forwards a context from the wrong navigator. Add a nested modal/navigator case that calls Navigator.pop(callbackContext) and asserts the intended picker modal is dismissed.

🤖 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/test/src/reactions/picker/reaction_picker_test.dart`
around lines 91 - 113, Extend the reaction picker test around
StreamMessageReactionPicker to use a nested navigator/modal and capture the
callback context supplied to onReactionSelected. Invoke Navigator.pop with that
callback context, then assert the intended picker modal is dismissed, ensuring
the picker forwards the correct nested-navigator context rather than ignoring
it.
🤖 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.

Outside diff comments:
In `@packages/stream_chat_flutter/lib/src/reactions/picker/reaction_picker.dart`:
- Around line 6-9: Restore OnReactionPicked to the legacy callback signature
accepting BuildContext and Reaction, and retain it as a deprecated typedef for
source compatibility. Update direct picker invocations to pass both arguments,
while keeping onReactionSelected as the new context-aware API.

---

Nitpick comments:
In
`@packages/stream_chat_flutter/test/src/reactions/picker/reaction_picker_test.dart`:
- Around line 91-113: Extend the reaction picker test around
StreamMessageReactionPicker to use a nested navigator/modal and capture the
callback context supplied to onReactionSelected. Invoke Navigator.pop with that
callback context, then assert the intended picker modal is dismissed, ensuring
the picker forwards the correct nested-navigator context rather than ignoring
it.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3c7ffde6-e8d8-4c0d-9c24-e942fa09036c

📥 Commits

Reviewing files that changed from the base of the PR and between 15a387a and 6c727f8.

📒 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
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/stream_chat_flutter/lib/src/message_widget/stream_message_item.dart
  • packages/stream_chat_flutter/lib/src/message_modal/message_actions_modal.dart

@w830207
w830207 requested a review from renefloor July 25, 2026 17:30
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