segmentio / evergreen

🌲 Evergreen React UI Framework by Segment
https://evergreen.segment.com
MIT License
12.38k stars 830 forks source link

`SideSheet` prevents page scroll even after closing, when `preventBodyScrolling` set to true #1619

Closed malimccalla closed 1 year ago

malimccalla commented 1 year ago

I'm using the <SideSheet /> component in the following way

        <SideSheet
          preventBodyScrolling={true} //  could also be `sheet.visible` and it has same effect.
          onCloseComplete={() => sheet.close()}
          width={420}
          isShown={sheet.visible}
          position="right"
        >
          <Profile />
        </SideSheet>

I'm controlling the visibility of the sheet with a basic hook that toggles sheet.visible via sheet.close() and sheet.open(). This is working as expected.

However, when using the preventBodyScrolling prop, I can no longer scroll on the page after closing the sheet

brandongregoryscott commented 1 year ago

Hey @malimccalla, can you provide a CodeSandbox for reproduction? I'm not seeing the described behavior: https://codesandbox.io/s/issue-1619-sidesheet-preventbodyscrolling-example-3f1sob?file=/src/App.tsx

malimccalla commented 1 year ago

Hi @brandongregoryscott. I will attempt to reproduce some point today. Opening my console I can see that body gets the styles

<body style="overflow: hidden; padding-right: 0px;">

but on closing the sheet they never go away. I will try recreate and send over a sandbox later today. I'm using both Emotion and Next.js

malimccalla commented 1 year ago

Will close this as I couldn't reproduce in a sandbox, and most likely related to some next.js SSR/emotion set up