Skip to content

Add scrolling case for longer user message#2995

Draft
Alexia-Claudia-Micu wants to merge 3 commits into
mainfrom
users/cmicu/3943833
Draft

Add scrolling case for longer user message#2995
Alexia-Claudia-Micu wants to merge 3 commits into
mainfrom
users/cmicu/3943833

Conversation

@Alexia-Claudia-Micu

Copy link
Copy Markdown
Contributor

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

  • I have updated the project documentation to reflect my changes or determined no changes are needed.

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;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@rajsite

rajsite commented Jun 30, 2026

Copy link
Copy Markdown
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.

@rajsite rajsite marked this pull request as draft June 30, 2026 15:32
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