-
Notifications
You must be signed in to change notification settings - Fork 236
fix(overlay): modal and page overlay should not allow body scroll #5710
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
Conversation
🦋 Changeset detectedLatest commit: efabcf9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 84 packages
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 |
📚 Branch Preview🔍 Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
Tachometer resultsChromeoverlay permalinkbasic-test
directive-test permalink
element-test permalink
lazy-test permalink
Firefoxoverlay permalinkbasic-test
directive-test permalink
element-test permalink
lazy-test permalink
|
nikkimk
left a comment
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.
LGTM with one nit on the changeset.
.changeset/grumpy-doors-worry.md
Outdated
| '@spectrum-web-components/overlay': minor | ||
| --- | ||
|
|
||
| **Fixed** : add body scroll prevention for modal and page overlays. Automatically block body scroll when modal or page overlays are open and restore the original scroll state when they are closed, improving user experience and accessibility for modal dialogs. |
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.
nit: Our writing changeset docs recommend using past tense.
| **Fixed** : add body scroll prevention for modal and page overlays. Automatically block body scroll when modal or page overlays are open and restore the original scroll state when they are closed, improving user experience and accessibility for modal dialogs. | |
| **Fixed** : Added body scroll prevention for modal and page overlays. Overlay automatically blocks body scroll when modal or page overlays are open and restores the original scroll state when they are closed, improving user experience and accessibility for modal dialogs. |
rubencarvalho
left a comment
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.
Solution looks great! 🚀 I just left one small comment about creating a more “e2e” style test to verify the scroll blocking.
| ).to.be.false; | ||
| }); | ||
|
|
||
| it('blocks body scroll when modal overlay is opened and restores when closed', async function () { |
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.
nit: could we also add a behavioral test that verifies the page actually can’t scroll while the modal is open (and can again after it closes)? Right now we’re checking the body overflow style, which is fine, but it’s still an implementation detail. I was thinking we could create a long enough page, attempt a scroll (e.g. window.scrollTo), and assert on window.scrollY.
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.
Certainly we can. Excellent suggestion!. We haven't explored these tests yet on our patterns but would love to add these for others too.
blunteshwar
left a comment
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.
LGTM
rubencarvalho
left a comment
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.
One little await and we can 🚢 it!
packages/overlay/test/index.ts
Outdated
|
|
||
| // Close modal overlay | ||
| const closed = oneEvent(modalTrigger, 'sp-closed'); | ||
| sendMouse({ |
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.
| sendMouse({ | |
| await sendMouse({ |
…roll (adobe#5710)" This reverts commit ee1bae6.
Description
This PR implements body scroll blocking functionality for modal and page overlays to prevent background content from scrolling while overlays are open
Motivation and context
Changes Made
Core Functionality
manageBodyScroll()method inOverlayStack.tsthat automatically blocks body scroll when modal or page overlays are presentbodyScrollBlockedflag andoriginalBodyOverflowpreservationImplementation Details
'modal' or type: 'page'is added to the stackdocument.body.style.overflowvalueRelated issue(s)
Screenshots (if appropriate)
Desktop

Mobile

Author's checklist
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
"modal" and "page" overlay should not have page scroll
Device review