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 unscrollable body when returning to desktop mode from mobile mode with navigation drawer open. #6201

Conversation

JustSNguyen
Copy link
Contributor

So, this PR is related to this issue: #6200. Currently, BlueSky blocks the body scroll when the navigation drawer is opened:

useWebBodyScrollLock(isDrawerOpen)

The problem is that when users switch to mobile mode, open the drawer, and then switch back to desktop mode, the navigation drawer is still considered open, which is incorrect. I’ve implemented a quick fix here to automatically close the drawer whenever the user exits mobile mode.

@JustSNguyen JustSNguyen changed the title Fix locked body element when resizing with the navigation menu open. Fix unscrollable body when returning to desktop mode from mobile mode with navigation drawer open. Nov 10, 2024
@gaearon
Copy link
Collaborator

gaearon commented Nov 11, 2024

The data flow is kind of backwards here. We shouldn't be setting state in an effect based on some other state — we should instead make the value which decides whether to render the drawer (presumably it's above in this case) the source of truth (or contribute to the source of truth). Is that possible?

@gaearon
Copy link
Collaborator

gaearon commented Nov 11, 2024

I think you can declare const showDrawer = !isDesktop && isDrawerOpen and then use that for the body scroll hook.

@JustSNguyen JustSNguyen force-pushed the fix/fix-locked-body-element-after-resizing branch from 72178b6 to c4ada8e Compare November 11, 2024 15:52
@JustSNguyen
Copy link
Contributor Author

Oh thanks @gaearon for your feedback, I think that would be better. I have updated the PR.

@gaearon gaearon merged commit 2728de0 into bluesky-social:main Nov 11, 2024
@gaearon
Copy link
Collaborator

gaearon commented Nov 11, 2024

thank you!

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