fix(chat): prevent display-name flicker and admin-badge duplication on hover#313
Open
novavale wants to merge 1 commit intoberkmancenter:mainfrom
Open
fix(chat): prevent display-name flicker and admin-badge duplication on hover#313novavale wants to merge 1 commit intoberkmancenter:mainfrom
novavale wants to merge 1 commit intoberkmancenter:mainfrom
Conversation
…n hover Hover state was stored as a bool field and updated via setState(), which triggered a full rebuild of MessageDisplayState — including UserInfoBuilder. During the rebuild UserInfoBuilder briefly re-entered the loading state, making snapshot.data null so the display name showed '...' instead of the actual name. The same rebuild caused Wrap to re-lay out its children, producing a momentary duplicate of the admin/mod badge. Fix: replace the bool field with a ValueNotifier<bool> and wrap only the Container in a ValueListenableBuilder. The message content Row is passed as the static argument and is reused unchanged when hover changes, so UserInfoBuilder is never re-triggered by hover events. Fixes berkmancenter#248
Collaborator
|
Hi @novavale, thank you so much for your contribution! I will test out these updates and provide a review early next week. Have a great weekend! |
There was a problem hiding this comment.
Pull request overview
This PR addresses a Flutter chat UI hover regression where message header content (display name and admin/mod badge) visually flickered/duplicated due to hover-triggered full widget rebuilds.
Changes:
- Replaced hover tracking from
setState-backedboolto aValueNotifier<bool>to avoid rebuilding the full widget subtree on hover. - Wrapped only the background
Containerin aValueListenableBuilder, passing the message content as the staticchildto preventUserInfoBuilderfrom being retriggered.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #248
When hovering over a chat message, two visual bugs appeared:
...Root Cause
MessageDisplayStatestored hover state as aboolfield and calledsetState()on enter/exit. This triggered a full rebuild of the widget, includingUserInfoBuilder. During that rebuildUserInfoBuilderbriefly re-entered its loading state, makingsnapshot.data == nulland causing the display name to fall back to'...'. The same rebuild causedWrapto re-lay out its children, producing a momentary duplicate paint of the admin badge.Fix
Replace the
bool _isHoveredfield with aValueNotifier<bool>and wrap only the backgroundContainerin aValueListenableBuilder. The message contentRowis passed as the staticchildargument ofValueListenableBuilder— Flutter reuses it unchanged when the notifier fires, soUserInfoBuilderis never re-triggered by a hover event.Testing