Skip to content

Commit

Permalink
[Feat] 스크롤 최상단 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
pu2rile committed Aug 8, 2024
1 parent 534a648 commit 8187758
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/components/CardAddPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import CardForm from './CardForm';
import Modal from './Modal';
import './CardAddPage.css';
Expand All @@ -12,6 +12,12 @@ const CardAddPage = ({ addCard, isOpen, onClose }) => {
password: ''
});

useEffect(() => {
if (isOpen) {
window.scrollTo(0, 0);
}
}, [isOpen]);

const handleAddCard = (newCard) => {
addCard(newCard);
onClose(); // 모달 닫기
Expand Down
8 changes: 7 additions & 1 deletion src/components/CardManagement.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import React from 'react';
import React, { useEffect } from 'react';
import AddCardButton from './AddCardButton';
import RegisteredCard from './RegisteredCard';
import Modal from './Modal';

const CardManagement = ({ cards, isOpen, onClose, openCardAddPage }) => {
useEffect(() => {
if (isOpen) {
window.scrollTo(0, 0);
}
}, [isOpen]);

const handleAddCard = () => {
openCardAddPage();
};
Expand Down

0 comments on commit 8187758

Please sign in to comment.