Skip to content

Commit ca35d2e

Browse files
committed
fix: 코드 수정
1 parent 1252046 commit ca35d2e

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

src/components/common/Modal/SeatModal/SeatFocusModal.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,35 @@ const SeatFocusModal = ({
1717
theaterName,
1818
selectedSeatNumbers,
1919
onClose,
20+
focusedSeatIds,
2021
}: SeatFocusModalProps) => {
2122
const containerRef = useRef<HTMLDivElement>(null);
2223
const innerRef = useRef<HTMLDivElement>(null);
2324

2425
const seatIds = selectedSeatNumbers.map((num) => getSeatLabel(auditoriumId, num));
2526

2627
useEffect(() => {
27-
const container = containerRef.current;
28-
const target = container?.querySelector('[data-seat-focus="true"]') as HTMLDivElement;
28+
const timer = setTimeout(() => {
29+
const container = containerRef.current;
30+
const target = container?.querySelector('[data-seat-focus="true"]') as HTMLDivElement;
2931

30-
if (container && target) {
31-
const containerRect = container.getBoundingClientRect();
32-
const targetRect = target.getBoundingClientRect();
32+
if (container && target) {
33+
const containerRect = container.getBoundingClientRect();
34+
const targetRect = target.getBoundingClientRect();
3335

34-
const scrollTop = container.scrollTop + (targetRect.top - containerRect.top) - 100;
35-
const scrollLeft = container.scrollLeft + (targetRect.left - containerRect.left) - 50;
36+
const scrollTop = container.scrollTop + (targetRect.top - containerRect.top) - 100;
37+
const scrollLeft = container.scrollLeft + (targetRect.left - containerRect.left) - 50;
3638

37-
container.scrollTo({
38-
top: scrollTop,
39-
left: scrollLeft,
40-
behavior: 'smooth',
41-
});
42-
}
43-
}, []);
39+
container.scrollTo({
40+
top: scrollTop,
41+
left: scrollLeft,
42+
behavior: 'smooth',
43+
});
44+
}
45+
}, 50);
46+
47+
return () => clearTimeout(timer);
48+
}, [focusedSeatIds]);
4449

4550
return (
4651
<div className="fixed inset-0 z-50">

0 commit comments

Comments
 (0)