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

Fix layout shift caused by redundant styles #6865

Merged
merged 1 commit into from
Jul 20, 2024

Conversation

monochromer
Copy link
Contributor

@monochromer monochromer commented Jun 27, 2024

Description

Initially, @shoaibkh4n noticed that when opening and closing the drop-down list on the page https://nodejs.org/en/download layout-shift occurs and suggested a solution – add scrollbar-gutter: stable;.

This really helped, but it led to an empty space on other pages equal to the size of the scrollbar (by the way, this happens only in SPA mode). @daklay noticed this and suggested setting scrollbar-gutter: auto, but this is unnecessary, since it is the default value.

In fact, Radix UI Dropdown Menu is already solving this problem, but it was prevented by the thoughtless assignment of such styles:

html,
body {
  width: 100%;
}

There is a difference between width: 100% and width: auto. Therefore, you just need to delete these styles.

Validation

After this changes no layout shift and empty spaces on other pages:

screen.mp4

Related Issues

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run npm run format to ensure the code follows the style guide.
  • I have run npm run test to check if all tests are passing.
  • I have run npx turbo build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

@monochromer monochromer requested a review from a team as a code owner June 27, 2024 10:54
Copy link

vercel bot commented Jun 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nodejs-org ✅ Ready (Inspect) Visit Preview Jul 5, 2024 0:12am

@shoaibkh4n
Copy link
Contributor

I think its a great suggestion, scrollbar-gutter: stable actually caused the issue on empty space on all pages thanks @monochromer for noticing this, LGTM 🔥👍,

@ovflowd
Copy link
Member

ovflowd commented Jun 28, 2024

Im pretty sure we added scrollbar-gutter and then removed for some reasons...

@canerakdas any insights here? 🤔

@canerakdas
Copy link
Member

Im pretty sure we added scrollbar-gutter and then removed for some reasons...

@canerakdas any insights here? 🤔

We removed it in this PR because it looks better and did not create a layout shift

What I don't understand is that I couldn't find this fix in the Radix primitives changelog 🤔

@ovflowd
Copy link
Member

ovflowd commented Jun 29, 2024

What I don't understand is that I couldn't find this fix in the Radix primitives changelog 🤔

Not sure I got your comment, are you saying a recent change on the Primitives created such layout shift?

@canerakdas
Copy link
Member

Not sure I got your comment, are you saying a recent change on the Primitives created such layout shift?

I mean I think the recent changes fixed the layout shift. Even though I reverted all changes, I couldn't reproduce the layout shift issue 🤷‍♂️

@monochromer
Copy link
Contributor Author

monochromer commented Jul 2, 2024

Most likely, Radix Dropdown has a solution to eliminate layout shift from the very beginning. But the styles html, body { width: 100%; } prevent it from working correctly. And any scrollbar-gutter setting in this case is simply superfluous.

@bmuenzenmeyer
Copy link
Collaborator

This PR will need to be rebased or recreated now that #6850 merged.

@monochromer
Copy link
Contributor Author

This PR will need to be rebased or recreated now that #6850 merged.

done

@ovflowd ovflowd added accessibility Issues concerning accessibility github_actions:pull-request Trigger Pull Request Checks labels Jul 20, 2024
@github-actions github-actions bot removed the github_actions:pull-request Trigger Pull Request Checks label Jul 20, 2024
Copy link
Member

@ovflowd ovflowd left a comment

Choose a reason for hiding this comment

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

LGTM!

@ovflowd ovflowd enabled auto-merge July 20, 2024 15:02
Copy link
Contributor

Unit Test Coverage Report

Unit Test Report

Tests Skipped Failures Errors Time
131 0 💤 0 ❌ 0 🔥 5.378s ⏱️

@ovflowd ovflowd disabled auto-merge July 20, 2024 15:21
@ovflowd ovflowd merged commit 9778b27 into nodejs:main Jul 20, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility Issues concerning accessibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants