Skip to content

Commit

Permalink
Merge pull request #211 from DevKor-github/fix/modal-scroll
Browse files Browse the repository at this point in the history
fix: Modal 열렸을 때 스크롤 방지
  • Loading branch information
halionaz authored Sep 29, 2024
2 parents d6d5de6 + a2c9e6b commit efd8976
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
12 changes: 11 additions & 1 deletion components/RankModal/RankModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use client';
import { useEffect } from 'react';
import styled from 'styled-components';

import { Flex } from '@/libs/design-system/flex';
import { Icon } from '@/libs/design-system/icons';
import styled from 'styled-components';
import Backdrop from '../Backdrop';
import { useRankShare } from './useRankShare';
import RankCard from './RankCard';
Expand All @@ -13,6 +15,14 @@ interface ShareModalProps {

export function RankModal({ isModalOpen = true, onClose }: ShareModalProps) {
const { imgSrc, rankInfo, isFetchLoading, imageRef, shareRef, shareImage } = useRankShare();

useEffect(() => {
document.body.style.cssText = `overflow: hidden;`;
return () => {
document.body.style.cssText = `overflow: auto;`;
};
}, []);

return (
<>
{isModalOpen && !isFetchLoading && rankInfo && imgSrc && (
Expand Down
11 changes: 10 additions & 1 deletion components/ShareModal/ShareModal.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
'use client';
import { useEffect } from 'react';
import styled from 'styled-components';

import { Flex } from '@/libs/design-system/flex';
import { Icon } from '@/libs/design-system/icons';
import PredictionCard from './PredictionCard';
import styled from 'styled-components';
import Backdrop from '../Backdrop';
import { useCardShare } from './useCardShare';

Expand All @@ -15,6 +17,13 @@ export function ShareModal({ isModalOpen = true, onClose }: ShareModalProps) {
const { shareImage, shareRef, imageRef, profile, scoreData, isLoading, isFetchLoading, imgSrc, predictionResult } =
useCardShare();

useEffect(() => {
document.body.style.cssText = `overflow: hidden;`;
return () => {
document.body.style.cssText = `overflow: auto;`;
};
}, []);

return (
<>
{isModalOpen && scoreData && profile && !isFetchLoading && predictionResult && imgSrc && (
Expand Down

0 comments on commit efd8976

Please sign in to comment.