Skip to content
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

Replacing a Dialog with another once causes layout shift #2901

Open
alexliebler opened this issue May 15, 2024 · 1 comment
Open

Replacing a Dialog with another once causes layout shift #2901

alexliebler opened this issue May 15, 2024 · 1 comment

Comments

@alexliebler
Copy link

Bug report

Current Behavior

To prevent scrolling contents behind a dialog overlay, the body's overflow is removed and it receives a marginRight of the scrollbar's width.
However, if one dialog replaces another one, the body is updated with an additional paddingRight of the same width, causing a layout shift.

Expected behavior

The padding should not be set. Keeping it the margin should be sufficient.

Reproducible example

CodeSandbox Template

Suggested solution

n/a

Additional context

This can be solved with using a timeout, but this only produces inconsistent results.

Your environment

Software Name(s) Version
Radix Package(s) @radix-ui/react-dialog 1.0.5
React 18.2.0
Browser Chrome 124.0.6367.201
Assistive tech n/a
Node n/a
npm/yarn
Operating System macOS 14.4.1
@joaom00
Copy link
Contributor

joaom00 commented May 18, 2024

Try

setIsModal1Visible(false);
setTimeout(() => setIsModal2Visible(true));

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

No branches or pull requests

2 participants