Add scrolling case for longer user message#2995
Draft
Alexia-Claudia-Micu wants to merge 3 commits into
Draft
Conversation
rajsite
reviewed
Jun 30, 2026
Comment on lines
+227
to
+239
| private getAnchorScrollTarget(message: ChatMessage): number { | ||
| const container = this.conversation.messagesContainer; | ||
| const containerRect = container.getBoundingClientRect(); | ||
| const messageRect = message.getBoundingClientRect(); | ||
| const messageTopInContainer = messageRect.top - containerRect.top + container.scrollTop; | ||
| const { clientHeight } = container; | ||
| const maxMessageCoverage = clientHeight * anchoredMessageMaxViewportFraction; | ||
| if (messageRect.height > maxMessageCoverage) { | ||
| return messageTopInContainer + messageRect.height - maxMessageCoverage; | ||
| } | ||
| return messageTopInContainer; | ||
| } | ||
|
|
Member
There was a problem hiding this comment.
A couple of concerns with this PR:
- If you notice from the previous refactor, a significant effort was put in to avoid manual calculations like this to measure the dom and instead rely on native CSS browser features. Please take some time to brainstorm and consider how this can be done in CSS with the browser native layout system instead of manually calculating layout. Things like this should be a last resort with comments describing approaches considered.
- This PR adds no tests. Notice the previous refactor includes tests to cover behavior. Please review and add tests
- This change is not covered by storybook matrix tests. Make sure this case is covered in storybook matrix snapshot testing to prevent regressions.
Member
|
Talked to @Alexia-Claudia-Micu and they'll be OOO for a few weeks and can address feedback when back. Moving to draft for now. |
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.
Pull Request
🤨 Rationale
https://dev.azure.com/ni/DevCentral/_workitems/edit/3897966
https://dev.azure.com/ni/DevCentral/_workitems/edit/3943833
👩💻 Implementation
Added
anchoredMessageMaxViewportFraction= 0.2 to keep the user message within that height in the viewport.🧪 Testing
Example app testing.
✅ Checklist