-
Notifications
You must be signed in to change notification settings - Fork 115
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
Add option to Dialog to permit/disable page scrolling #3145
Conversation
🦋 Changeset detectedLatest commit: f2980ea The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:has
is technically supported now, think you should try and test this on a browser that doesn't support :has just to see what a fail case might look like
@jonrohan just verified that the failure case simply allows the page to scroll, which I don't think is a blocker. There's also a scroll gutter property that won't apply, but that also doesn't seem to affect functionality. |
What are you trying to accomplish?
The
SelectPanel
component uses parts of theDialog
component under the hood, which comes with custom CSS that prevents the page from scrolling when the dialog is opened as a modal. This means thatSelectPanel
s, despite behaving more like popovers, prevent page scrolling too. We'd like to enable scrolling forSelectPanel
s but keep the existing behavior for other dialogs.Integration
No changes necessary in production.
List the issues that this change affects.
Closes https://github.com/github/primer/issues/4126
Risk Assessment
What approach did you choose and why?
I refactored our CSS rules and added a parameter to
Dialog
that conditionally adds the.Overlay--disableScroll
CSS class to the<dialog>
element. The parameter defaults totrue
to preserve existing behavior.Since we can use it now, I also switched to using
body:has(...)
instead of the hackishbody.has-modal
selector for applying the scroll gutter and scroll disabling rules.Anything you want to highlight for special attention from reviewers?
I really tried to write a test for this, but wasn't able to figure out how to simulate scrolling appropriately. If scrolling is disabled in CSS via
overflow: hidden
, JavaScript'sscroll
,scrollTo
, andscrollBy
functions scroll the page anyway. Firing manually-createdwheel
andtouch
events also didn't work - the page never scrolls, even whenoverflow
is not set tohidden
. If y'all have any ideas here, I'm all ears.Accessibility
Merge checklist
- [ ] Added/updated testsTake a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.