fix: 🐛 reply configuration not working with a custom text field.#428
fix: 🐛 reply configuration not working with a custom text field.#428japanshah-simform wants to merge 1 commit intomainfrom
Conversation
d492da8 to
f412e36
Compare
There was a problem hiding this comment.
Pull request overview
Updates the send-message composer so reply UI/configuration is applied even when a custom text field (sendMessageBuilder) is used.
Changes:
- Refactors
SendMessageWidgetto always renderReplyMessageView(and selected-image UI), while still supporting a custom text field widget. - Adds a post-frame scroll-to-bottom when assigning a reply message.
- Updates the example custom chat bar to remove its manual reply UI, relying on the shared reply view instead, and documents the fix in the changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/src/widgets/send_message_widget.dart | Always composes reply + selected-image UI regardless of custom/default input; adds scroll-to-bottom on reply assignment. |
| example/lib/widgets/custom_chat_bar.dart | Removes duplicated reply UI from the custom composer example. |
| CHANGELOG.md | Adds an entry documenting the fix for custom text fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| sendMessageConfig: widget.sendMessageConfig, | ||
| messageConfig: widget.messageConfig, | ||
| builder: widget.replyMessageBuilder, | ||
| onChange: (value) => _replyMessage = value, |
There was a problem hiding this comment.
With sendMessageBuilder (custom text field), the builder depends on the ReplyMessage argument to attach reply metadata when sending. After this refactor, _replyMessage is updated via ReplyMessageView(onChange: ...) without calling setState, so the custom sendMessageBuilder widget may not rebuild when the reply message is set/cleared. That can leave the custom UI holding a stale ReplyMessage and sending incorrect reply info.
Consider triggering a rebuild when the reply message changes (e.g., call setState inside onChange when widget.sendMessageBuilder != null, or otherwise make the custom builder listen to the reply message changes).
| onChange: (value) => _replyMessage = value, | |
| onChange: (value) { | |
| if (isCustomTextField) { | |
| setState(() => _replyMessage = value); | |
| } else { | |
| _replyMessage = value; | |
| } | |
| }, |
f412e36 to
f09ea60
Compare
| if (_replyMessage?.message.isNotEmpty ?? false) | ||
| Container( | ||
| padding: const EdgeInsets.fromLTRB(8, 8, 7.5, 7.5), | ||
| decoration: const BoxDecoration( | ||
| border: Border( | ||
| left: BorderSide( | ||
| color: AppColors.uiTwoReplyLineColor, | ||
| width: 4, | ||
| ), | ||
| ), | ||
| ), | ||
| child: Row( | ||
| children: [ | ||
| Expanded( | ||
| child: Column( | ||
| crossAxisAlignment: CrossAxisAlignment.start, | ||
| children: [ | ||
| Text( | ||
| replyTo, | ||
| style: const TextStyle( | ||
| fontStyle: FontStyle.normal, | ||
| fontWeight: FontWeight.w600, | ||
| fontSize: 14, | ||
| height: 1.3571428571, | ||
| letterSpacing: -0.01, | ||
| color: Color(0xFFD42A66), | ||
| ), | ||
| ), | ||
| const SizedBox(height: 1.5), | ||
| Text( | ||
| _replyMessage?.message ?? '', | ||
| style: const TextStyle( | ||
| fontSize: 12, | ||
| height: 1.33, | ||
| color: Color(0xFF0A0A0A), | ||
| ), | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| const SizedBox(width: 16), | ||
| SizedBox.square( | ||
| dimension: 32, | ||
| child: IconButton( | ||
| onPressed: () => ChatView.closeReplyMessageView( | ||
| context, | ||
| ), | ||
| padding: EdgeInsets.zero, | ||
| icon: SvgPicture.asset(AppIcons.closeCircular), | ||
| ), | ||
| ), | ||
| ], | ||
| ), | ||
| ), |
There was a problem hiding this comment.
Please migrate this reply view to replyMessageBuilder
| // Scroll to ensure the reply widget is visible and messages are not overlapped | ||
| WidgetsBinding.instance.addPostFrameCallback((_) { | ||
| chatViewIW?.chatController.scrollToLastMessage(); | ||
| }); |
There was a problem hiding this comment.
Please review this, as the view scrolls down every time a user tries to reply to a message.
Description
The
repliedMessageConfigwill now be used in case of custom text field also.Checklist
fix:,feat:,docs:etc).docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Related Issues