fix(ui): pass the correct BuildContext to onReactionPicked (#1234)#2823
fix(ui): pass the correct BuildContext to onReactionPicked (#1234)#2823w830207 wants to merge 2 commits into
onReactionPicked (#1234)#2823Conversation
…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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe reaction picker callback now receives a ChangesReaction picker context callback
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/stream_chat_flutter/lib/src/reactions/picker/reaction_picker.dart (1)
35-35: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSpecify the
voidreturn type for strict typing.The previous
ValueSetter<Reaction>typedef inherently enforced avoidreturn type. Changing the field toFunction(Reaction, BuildContext)?makes the return typedynamic. It is recommended to explicitly declare thevoidreturn 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
📒 Files selected for processing (4)
packages/stream_chat_flutter/lib/src/message_modal/message_actions_modal.dartpackages/stream_chat_flutter/lib/src/message_widget/stream_message_item.dartpackages/stream_chat_flutter/lib/src/reactions/picker/reaction_picker.dartpackages/stream_chat_flutter/test/src/reactions/picker/reaction_picker_test.dart
| final Message message; | ||
|
|
||
| /// {@macro onReactionPicked} | ||
| final OnReactionPicked? onReactionPicked; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Thanks for the feedback. That's a great suggestion.
I can make this change. Do you have any recommendations for the new method name?
onReactionPickedPass the appropriate
BuildContextto theonReactionPickedcallback so navigation uses the correct context.Submit a pull request
Linear: FLU-
Github Issue: #
CLA
Description of the pull request
This PR fixes an issue where
onReactionPickedcould receive an incorrectBuildContext.When the reaction picker is used within nested navigators, using the wrong
BuildContextmay cause navigation operations (such asNavigator.pop) to target the wrong navigator, resulting in the parent page being closed unexpectedly.This change passes the correct
BuildContexttoonReactionPicked, ensuring navigation is performed on the intended navigator.Changes included:
BuildContexttoonReactionPicked.BuildContext.Screenshots / Videos
Summary by CodeRabbit
BuildContextalongside the selected reaction, ensuring consistent behavior across platforms.