Skip to content

Commit a3c9b5d

Browse files
committed
refactor: 스크롤바 너비만큼 padding-right 추가
1 parent 292a1bc commit a3c9b5d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/shared/components/Modal/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,19 @@ export const Modal = ({
156156

157157
// 배경 스크롤 방지 (modal variant만)
158158
const originalOverflow = document.body.style.overflow;
159+
const originalPaddingRight = document.body.style.paddingRight;
159160
if (variant === 'modal') {
161+
// 스크롤바 너비 계산
162+
const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
160163
document.body.style.overflow = 'hidden';
164+
document.body.style.paddingRight = `${scrollbarWidth}px`;
161165
}
162166

163167
return () => {
164168
document.removeEventListener('keydown', handleKeyDown);
165169
if (variant === 'modal') {
166170
document.body.style.overflow = originalOverflow;
171+
document.body.style.paddingRight = originalPaddingRight;
167172
}
168173
};
169174
}

0 commit comments

Comments
 (0)