question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrapped Page Is Still Scrollable

See original GitHub issue

Currently with an implementation like the following: App:

      <div id="outer-container" className="forecast-page-container">
        <Menu
          pageWrapId={'page-wrap'}
          outerContainerId={'outer-container'}
          options={this.regions}
          {...this.props}
        />
        <div id="page-wrap" className={'forecast-page full-width'}>
          <Navbar />
          <ForecastPage {...this.props} />
        </div>
      </div>

Menu:

      <ReduxBurgerMenu
        pageWrapId={this.props.pageWrapId}
        outerContainerId={this.props.outerContainerId}
        isOpen={this.props.burgerMenu.isOpen}
        right
        customBurgerIcon={false}
      >
        .... Some items in the menu
      </ReduxBurgerMenu>

When the menu is open I am still able to scroll the page-wrap div element. Since I have a list of items in my menu, and it is scrollable this creates a really weird interaction.

Is there any way to lock the scrolling on the page-wrap item.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
zeckdudecommented, Mar 30, 2018

Thanks to @monsonjeremy’s suggestion, I followed the same approach, since I wasn’t able to get any of the other suggestions to work.

In case anyone finds value, here’s my code snippet:

componentDidUpdate(prevProps, prevState) {
  // If the hamburger menu is open, disable scrolling on the site
  if (prevState.menuOpen !== this.state.menuOpen) {
    if (this.state.menuOpen) {
      // overflow:hidden disables the scrolling on a desktop browser
      // position: fixed is additionally needed for mobile devices
      document.body.setAttribute("style", "overflow: hidden; position: fixed;");
    } else {
      document.body.setAttribute("style", "overflow: visible; position: static;");
    }
  }
}
2reactions
monsonjeremycommented, Sep 21, 2017

Thanks for the reply @negomi, I ended up finding a workaround by checking the state of the menu and if it is open I set the Document Body style to have overflow: hidden.

This seems like a hacky workaround, but for some reason setting overflow: hidden on the page wrap element wasn’t doing it. I have the overlay as well so i’m not sure why.

Here are the relevant files if you want to take a look:

Component where I put items in the menu: https://github.com/monsonjeremy/Forecast-Me/blob/master/client/src/components/SpotSelectDrawer.jsx

Container where i do the page-wrap: https://github.com/monsonjeremy/Forecast-Me/blob/master/client/src/containers/ForecastPageContainer.jsx

ReduxBurgerMenu container: https://github.com/monsonjeremy/Forecast-Me/blob/master/client/src/containers/ReduxBurgerMenu.jsx

Read more comments on GitHub >

github_iconTop Results From Across the Web

Body set to overflow-y:hidden but page is still scrollable in ...
Scroll works fine in the inner container, but the event doesn't propagate to the body and so it does not scroll. This is...
Read more >
How to prevent overflow scrolling in CSS - LogRocket Blog
What causes the overflow scroll issue? Max viewport width; CSS grid; Not wrapping with Flexbox; Using images without max-width.
Read more >
overscroll-behavior - CSS: Cascading Style Sheets | MDN
If you have overscroll-behavior: contain; selected, the outer container will not scroll unless you move your cursor out of the inner ...
Read more >
Overflow Issues In CSS - Smashing Magazine
The first way to discover an overflow issue is by scrolling the page horizontally. If you're able to scroll, this is a warning...
Read more >
Scrollable Page with Shrink Wrapped ListView
I'm still a little uncertain on the exact differentiation between 'primary' (scrolling) widgets and non-primary - as well as the exact usecase here...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found