Skip to content

XDSChatLayout: self-scroll mode shows a phantom scrollbar (~composer height) when messages don't fill the viewport #2573

Closed

Description

@rubyycheung

Summary

In its self-scrolling mode (no external scrollRef), XDSChatLayout always overflows its scroll container by exactly the composer/dock height, producing a phantom vertical scrollbar even when the messages are far shorter than the available height.

Root cause

packages/core/src/Chat/XDSChatLayout.tsx:

  • The root is the scroll container: styles.rootScrollable → overflowY: auto, and styles.root → flex: 1; minHeight: 0.
  • It has two in-flow children:
    1. messageArea — styles.messageArea sets minHeight: 100% (line ~128) plus paddingBlockEnd: --spacing-6.
    2. dockContainer (holds blur + scroll button + composer) — position: sticky; bottom: 0 (styles.dockContainerSticky, line ~155).

position: sticky elements still occupy space in normal flow. So total content height = messageArea (≥100% of container) + dock height. Because messageArea alone is already 100% of the container, the sticky dock adds its full height on top → the scroll container always overflows by the dock height.

Measured evidence

Playwright, viewport 1280×900, .xds-chat-layout element:

ai-chat-artifact template:   clientHeight 900,  scrollHeight 1086, diff 186
                             msgAreaHeight 900 (minHeight:100%), dockHeight 186 (sticky)
ai-chat template (sibling):  clientHeight 2349, scrollHeight 2535, diff 186
                             msgAreaHeight 2349 (minHeight:100%), dockHeight 186 (sticky)

The overflow (diff) equals the dock/composer height (186px) in both cases, regardless of message count — confirming it's structural, not content-driven. It reproduces on the unmodified ai-chat template, so it affects all XDSChatLayout consumers in self-scroll mode.

Expected

When messages don't fill the viewport, there should be no scrollbar — the composer docks at the bottom and the empty space sits above it.

Suggested fix (component-level)

A few options, in the component:

  • Make the message area reserve space for the dock rather than forcing full height — e.g. messageArea { min-height: 100% } only counts when content actually exceeds available height; or subtract the dock height: min-height: calc(100% - <dock-height>) (dock height could be a CSS var the dock sets).
  • Or take the dock out of flow in self-scroll mode too (the dock already uses position: fixed when an external scrollRef is provided — styles.dockContainerFixed). If the self-scroll root is the positioned ancestor, an absolutely-positioned dock pinned to the bottom would not add flow height.
  • Or render the dock as an overlay sibling of the scroll container rather than inside it.

Remember the SYNC: block at the top of XDSChatLayout.tsx (index exports, Storybook stories, ChatLayout block examples).

Context

Found while building the ai-chat-artifact page template. We did not work around it at the template level (every clean lever requires piercing the component's internal flex/sticky structure), so filing here. Related top-anchor gap: #2572.

Activity

  1. added
    bug
    component
    on Jun 10, 2026
  2. self-assigned this
    on Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugcomponent

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions