Skip to content

Popover left placement is offset by scrollbar gutter when using scrollbar-gutter: stable #10131

@lixiaoyan

Description

@lixiaoyan

Provide a general summary of the issue here

Popover positioning is incorrect for left-opening submenus when the document has a classic scrollbar and usePreventScroll applies scrollbar-gutter: stable to the root element.

The issue appears to be a coordinate-space mismatch:

  • The submenu popover is absolutely positioned in body, so CSS resolves its right value against the initial containing block (ICB).
  • React Aria's positioning calculation uses viewport-related dimensions, including visualViewport.width.
  • In Chrome, with scrollbar-gutter: stable on the root element, visualViewport.width / document.documentElement.clientWidth include the scrollbar gutter, while the ICB used by absolute positioning does not match that value.

Related Chromium issue:
https://issues.chromium.org/issues/503187943

🤔 Expected Behavior?

For a left-opening submenu with offset={0}, the submenu should touch the parent menu with no horizontal gap.

😯 Current Behavior

When the document is scrollable and Chrome uses classic/non-overlay scrollbars, opening the menu applies:

html {
  overflow: hidden;
  scrollbar-gutter: stable;
}

After that, the left-opening submenu is shifted horizontally and a gap appears between the parent menu and submenu.

If the document is not scrollable, the issue does not reproduce.

💁 Possible Solution

No response

🔦 Context

No response

🖥️ Steps to Reproduce

https://stackblitz.com/edit/sgw8huxe?file=src%2FExample.tsx

Image Image

Version

react-aria-components@1.17.0

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

macOS

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions