Skip to content

Set the disable scroll class after the scrollbar width is calculated #6281

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

Merged
merged 2 commits into from
Jul 3, 2025

Conversation

jonrohan
Copy link
Member

@jonrohan jonrohan commented Jul 3, 2025

follow up to #6266

The fix wasn't working because it was calculating the scrollbar width after it had already been disabled which was giving 0px. I'm going to skip the changeset since this is meant to be part of the other change.

@jonrohan jonrohan requested review from francinelucca and Copilot July 3, 2025 16:46
@jonrohan jonrohan added the skip changeset This change does not need a changelog label Jul 3, 2025
@jonrohan jonrohan requested a review from a team as a code owner July 3, 2025 16:46
Copy link

changeset-bot bot commented Jul 3, 2025

⚠️ No Changeset found

Latest commit: 5614478

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added staff Author is a staff member integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Jul 3, 2025
Copy link
Contributor

github-actions bot commented Jul 3, 2025

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the timing of setting the --dialog-scrollgutter CSS variable by calculating the scrollbar width before disabling scroll, and moves the DisableScroll class application from the rendered className to runtime via a ref.

  • Calculate scrollbarWidth before disabling scroll
  • Add classes.DisableScroll via dialogRef.current in a useEffect
  • Remove classes.DisableScroll from the static className prop
Comments suppressed due to low confidence (1)

packages/react/src/Dialog/Dialog.tsx:293

  • If the intent is to disable page scrolling, confirm that classes.DisableScroll targets the correct element (e.g., document.body) — otherwise the scroll lock may not work as expected on the dialog element.
    dialogRef.current?.classList.add(classes.DisableScroll)

Copy link
Contributor

github-actions bot commented Jul 3, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 92.42 KB (+0.04% 🔺)
packages/react/dist/browser.umd.js 92.55 KB (+0.07% 🔺)

@jonrohan jonrohan enabled auto-merge July 3, 2025 16:58
@jonrohan jonrohan disabled auto-merge July 3, 2025 17:16
@github-actions github-actions bot requested a deployment to storybook-preview-6281 July 3, 2025 17:20 Abandoned
@github-actions github-actions bot requested a deployment to storybook-preview-6281 July 3, 2025 17:39 Abandoned
@github-actions github-actions bot requested a deployment to storybook-preview-6281 July 3, 2025 19:39 Abandoned
@jonrohan jonrohan enabled auto-merge July 3, 2025 20:28
@github-actions github-actions bot requested a deployment to storybook-preview-6281 July 3, 2025 21:18 Abandoned
@jonrohan jonrohan added this pull request to the merge queue Jul 3, 2025
auto-merge was automatically disabled July 3, 2025 21:36

Pull Request is not mergeable

@jonrohan jonrohan removed this pull request from the merge queue due to a manual request Jul 3, 2025
@jonrohan jonrohan added this pull request to the merge queue Jul 3, 2025
Merged via the queue into main with commit 3fc91f8 Jul 3, 2025
34 of 74 checks passed
@jonrohan jonrohan deleted the dialog_scroll_fix_too branch July 3, 2025 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm skip changeset This change does not need a changelog staff Author is a staff member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants