Skip to content

Commit

Permalink
[landing] fix body scrolling when modal is active
Browse files Browse the repository at this point in the history
Summary:
As I was working on D8477, I noticed that I introduced a regression in D8175 where the page would still scroll even when a modal was active. With @Ashoat's help, we built this diff to fix this regression

{F632177}

Depends on D8477

Test Plan:
Please see the demo video to see that the scroll no longer works when the modal is active, and that the keyserver animations and scroll to top functionality on navigation still works

{F632171}

Reviewers: atul, kamil

Reviewed By: kamil

Subscribers: tomek, ashoat

Differential Revision: https://phab.comm.dev/D8480
  • Loading branch information
ginsueddy committed Aug 8, 2023
1 parent 790ce88 commit d1bdf88
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions landing/landing.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ function LandingSite(): React.Node {
[modalContext.modals],
);

const isModalOpen = modals.length > 0;
React.useEffect(() => {
const { body } = document;
if (!body || !isModalOpen) {
return undefined;
}

body.style.overflow = 'hidden';
return () => {
body.style.overflow = 'auto';
};
}, [isModalOpen]);

const [showMobileNav, setShowMobileNav] = React.useState<boolean>(false);

const handleResize = React.useCallback(() => {
Expand Down

0 comments on commit d1bdf88

Please sign in to comment.