Skip to content

[Bug]: useBodyScrollLock does not respect the existing padding/margin. #2800

Description

@arkida39

Environment

Developement/Production OS: Fedora Linux 43
Node version: 24.13.0
Package manager: pnpm@10.13.1
Reka UI version: 2.10.1
Vue version: 3.5.17
CSS framework: tailwindcss@3.4.17
Client OS: Windows 10 19043.1110
Browser: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36

Link to minimal reproduction

https://stackblitz.com/edit/u8c5pyzw-ydbu8qxu?file=index.html

Steps to reproduce

  1. Add large padding-right or margin-right to the body.
  2. Open the modal dialog. (will cause layout shift)
  3. Close the modal dialog. (will completely remove the initial paddings and margins)
Image Image Image

Describe the bug

The margin and padding are not respected when applying scroll-lock on the body:

  • the margin and padding are overwritten: padding-right simply becomes <scrollbarWidth>px, and margin-right becomes 0px;
  • after the unlock the padding-right and margin-right get completely erased, losing the initial styling;

Note: the body on the reproducer is blue, while the App.vue is red. After lock-unlock, the blue part is not visible anymore.

Expected behavior

The initial margin and padding are respected, e.g., if the initial padding-right was <X>px, then the locked should be <X + scrollbarWidth>px, while margin-right preserved as-is.

Context & Screenshots (if applicable)

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions