Scrim -> SideSheet + Dialog - Scrollbar does not reappear when closing both at the same time #3724
Description
Describe the bug
When opening a sidesheet and a dialog, then closing both at the same time (in the same function), the main scollbar does not reappear, and it is no longer possible to scroll the page.
There was a similar bug in an earlier version (0.41.4), which is in this issue: #3617
But in the previous case, it also happened when closing one at a time. This time, its just when closing both at the same time.
Seems like this bug has been here since since the previous one, we just didnt notice until now.
I found a workaround, adding a "sleep" in between closing the dialog and sidesheet like this, so react events are run in between them:
setShowDialog(false);
// This ensures that the dialog closes before the side sheet closes, which avoids the scrollbar disappearing
await new Promise((resolve) => setTimeout(resolve, 0));
setShowSidesheet(false);
Steps to reproduce the bug
- Have this structure Scrim -> Sidesheet -> Dialog, all of them wrapped in a createPortal to document.body.
- Open sidesheet, then open dialog
- Close both dialog and sidesheet in one function.
Expected behavior
The scrollbar comes back, and the page is scrollable again.
Specifications
- Version: 0.43.0
- Browser: Edge 132
- OS: Windows 11
Additional context
Minimal reproduction sandbox: CodeSandbox