Skip to content
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

Fix scrolling with drawer open #435

Merged
merged 3 commits into from
Sep 12, 2023
Merged

Conversation

serjonya-trili
Copy link
Contributor

@serjonya-trili serjonya-trili commented Sep 12, 2023

Proposed changes

Task

Chakra-ui uses this lib under the hood https://github.com/theKashey/react-remove-scroll
The problem is that it disables scrolling everywhere except for the current modal. drawer, according to chakra, is also a modal. and the scrolling block will apply to only one layer of nesting.

so, since dynamic modal content resides close to the root in DOM it is considered a lower level modal window by chakra and the scrolling blocks because of that when you open a drawer.

if you set blockScrollOnMount={false} for the drawers it'll fix the issue for scrolling inside the modal, but everything else will also become scrollable (like accounts list).

That's why I just disable this functionality provided by chakra for drawers and set it manually for the dynamic modal so that everything except for it is non-scrollable while it's open.

Also, I noticed that if you have lots of errors happening at the same time you could end up with repeated keys on the errors drawer. so, I used the same approach as with the batch page - nanoid. yes, it might cause rer-enders of all of the elements if they change anyhow, but:

  • it shouldn't happen often
  • it shouldn't happen when the drawer is open (unless there was an error during background data fetching)
  • it's limited to just 100 elements meaning that it's fine, not that many elements to re-render anyway

Types of changes

  • Bugfix
  • New feature
  • Refactor
  • Breaking change
  • UI fix

Steps to reproduce

Screenshots

Add the screenshots of how the app used to look like and how it looks now

Before Now

Checklist

  • Tests that prove my fix is effective or that my feature works have been added
  • Documentation has been added (if appropriate)
  • Screenshots are added (if any UI changes have been made)
  • All TODOs have a corresponding task created (and the link is attached to it)

If you open the drawer it should block scrolling of
the elements behind it, but once the dynamic modal opens
it should stop doing it, otherwise it'll block
the modal's scrolling too
@serjonya-trili serjonya-trili merged commit 387669e into main Sep 12, 2023
2 checks passed
@serjonya-trili serjonya-trili deleted the fix-scrolling-with-drawer-open branch September 12, 2023 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants