Skip to content

Commit

Permalink
Disable scrolling when drawer open, but modal isn't
Browse files Browse the repository at this point in the history
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
  • Loading branch information
serjonya-trili committed Sep 12, 2023
1 parent cdba5d7 commit bb63efe
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/views/home/AccountListWithDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import AccountCard from "../../components/AccountDrawer";
import { useAllAccounts } from "../../utils/hooks/accountHooks";
import { AccountsList } from "./AccountsList";
import { DrawerTopButtons } from "./DrawerTopButtons";
import { useDynamicModal } from "../../components/DynamicModal";

const AccountListWithDrawer: React.FC = () => {
const [selected, setSelected] = useState<string | null>(null);
const allAccounts = useAllAccounts();

const { isOpen, onClose: closeDrawer, onOpen } = useDisclosure();
const { isOpen: isDynamicModalOpen } = useDynamicModal();

const handleClose = () => {
setSelected(null);
Expand All @@ -28,7 +30,7 @@ const AccountListWithDrawer: React.FC = () => {
}}
/>
<Drawer
blockScrollOnMount={false}
blockScrollOnMount={!isDynamicModalOpen}
isOpen={isOpen}
placement="right"
onClose={handleClose}
Expand Down
4 changes: 3 additions & 1 deletion src/views/nfts/NftsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import { useAllNfts } from "../../utils/hooks/assetsHooks";
import { DrawerTopButtons } from "../home/DrawerTopButtons";
import NFTDrawerCard from "./NFTDrawerCard";
import NFTGallery from "./NFTGallery";
import { useDynamicModal } from "../../components/DynamicModal";

const NFTsViewBase = () => {
const nfts = useAllNfts();
const { accountsFilter, selectedAccounts } = useAccountsFilter();
const navigate = useNavigate();
const { ownerPkh, nftId } = useParams();
const { isOpen: isDynamicModalOpen } = useDynamicModal();

const openNFTsPage = useCallback(() => {
navigate(`/nfts`);
Expand Down Expand Up @@ -58,7 +60,7 @@ const NFTsViewBase = () => {
</Box>

<Drawer
blockScrollOnMount={false}
blockScrollOnMount={!isDynamicModalOpen}
placement="right"
onClose={openNFTsPage}
size="md"
Expand Down
5 changes: 3 additions & 2 deletions src/views/settings/BeaconDrawerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ import { SettingsCardWithDrawerIcon } from "../../components/ClickableCard";
import { useAddPeer } from "../../utils/beacon/beacon";
import BeaconPeers from "../../utils/beacon/BeaconPeers";
import { DrawerTopButtons } from "../home/DrawerTopButtons";
import { useDynamicModal } from "../../components/DynamicModal";

export const BeaconDrawerCard = () => {
const { isOpen, onClose: closeDrawer, onOpen } = useDisclosure();

const { isOpen: isDynamicModalOpen } = useDynamicModal();
return (
<>
<SettingsCardWithDrawerIcon left="dApps" onClick={onOpen} />
<Drawer
blockScrollOnMount={false}
blockScrollOnMount={!isDynamicModalOpen}
isOpen={isOpen}
placement="right"
onClose={closeDrawer}
Expand Down
4 changes: 3 additions & 1 deletion src/views/settings/ErrorLogsDrawerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import { ErrorContext } from "../../utils/getErrorContext";
import { useAppSelector } from "../../utils/redux/hooks";
import { DrawerTopButtons } from "../home/DrawerTopButtons";
import { nanoid } from "@reduxjs/toolkit";
import { useDynamicModal } from "../../components/DynamicModal";

const ErrorLogsDrawerCard = () => {
const { isOpen, onClose: closeDrawer, onOpen } = useDisclosure();
const { isOpen: isDynamicModalOpen } = useDynamicModal();

const handleClose = () => {
closeDrawer();
Expand All @@ -30,7 +32,7 @@ const ErrorLogsDrawerCard = () => {
<>
<SettingsCardWithDrawerIcon left="ErrorLogs" onClick={onOpen} />
<Drawer
blockScrollOnMount={false}
blockScrollOnMount={!isDynamicModalOpen}
isOpen={isOpen}
placement="right"
onClose={handleClose}
Expand Down

0 comments on commit bb63efe

Please sign in to comment.