Skip to content

fix(Chat): ui.Chat() should never scroll a parent element of the chat container element #1996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 13, 2025

Conversation

cpsievert
Copy link
Collaborator

@cpsievert cpsievert commented May 12, 2025

Discovered via posit-dev/shinychat#42

Here is a minimal Python equivalent reprex. Note that, on load, the page scrolls down past the chat container. It shouldn't scroll at all.

from shiny.express import ui

chat = ui.Chat(
    id="chat",
    messages=[
        (
            "Hello! How can I help you today?\n\n"
            "Hello! How can I help you today?\n\n"
            "Hello! How can I help you today?\n\n"
            "Hello! How can I help you today?\n\n"
            "Hello! How can I help you today?\n\n"
            "Hello! How can I help you today?\n\n"
        )
    ],
)

with ui.card():
    chat.ui()

ui.div(style="height:3000px")

@cpsievert cpsievert requested a review from Copilot May 12, 2025 22:24
Copilot

This comment was marked as outdated.

@cpsievert cpsievert requested a review from gadenbuie May 12, 2025 22:30
Copy link
Collaborator

@gadenbuie gadenbuie left a comment

Choose a reason for hiding this comment

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

Looks good! Just one more nitpick on top of Copilot's suggested change

@cpsievert cpsievert enabled auto-merge (squash) May 13, 2025 20:07
@cpsievert cpsievert merged commit 0e0f186 into main May 13, 2025
53 of 54 checks passed
@cpsievert cpsievert deleted the fix/chat-scroll-parent branch May 13, 2025 20:13
@gadenbuie
Copy link
Collaborator

This doesn't completely solve the problem. I think it fixed the issue for the reprex app because the card scrolls, but when the card doesn't scroll the parent container still scrolls. I.e. changing out page_fluid() for Shiny Express's default page_fillable() still exhibits the problem.

@gadenbuie
Copy link
Collaborator

Turns out el.TagName returns SHINY-CHAT-MESSAGES (at least on Chrome). Fix incoming.

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