-
Notifications
You must be signed in to change notification settings - Fork 2
fix: (QA/3) dim scroll 문제 해결 #368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,9 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const handleScrollLock = (isOpen: boolean) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (isOpen) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.body.style.overflow = 'hidden'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.body.style.touchAction = 'none'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.body.style.removeProperty('overflow'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.body.style.removeProperty('touch-action'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 동시 오버레이에서 잠금이 풀릴 수 있는 경쟁 상태 — ref-count와 복원 로직으로 교체 필요 Home/BottomSheet가 각각 토글하면 한 쪽이 닫힐 때 다른 쪽이 열려 있어도 스크롤 잠금이 해제될 수 있습니다. SSR/초기 렌더에서도 안전 가드가 필요합니다. 아래처럼 참조 카운트, 이전 스타일 복원, 환경 가드를 추가해 주세요. -export const handleScrollLock = (isOpen: boolean) => {
- if (isOpen) {
- document.body.style.overflow = 'hidden';
- document.body.style.touchAction = 'none';
- } else {
- document.body.style.removeProperty('overflow');
- document.body.style.removeProperty('touch-action');
- }
-};
+let scrollLockCount = 0;
+let prevOverflow: string | null = null;
+let prevTouchAction: string | null = null;
+
+export const handleScrollLock = (lock: boolean) => {
+ if (typeof document === 'undefined' || !document.body) return;
+ const style = document.body.style;
+
+ if (lock) {
+ if (scrollLockCount === 0) {
+ prevOverflow = style.overflow || '';
+ prevTouchAction = style.touchAction || '';
+ style.overflow = 'hidden';
+ style.touchAction = 'none';
+ }
+ scrollLockCount += 1;
+ } else {
+ scrollLockCount = Math.max(0, scrollLockCount - 1);
+ if (scrollLockCount === 0) {
+ if (prevOverflow) style.overflow = prevOverflow; else style.removeProperty('overflow');
+ if (prevTouchAction) style.touchAction = prevTouchAction; else style.removeProperty('touch-action');
+ prevOverflow = null;
+ prevTouchAction = null;
+ }
+ }
+};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
렌더 중 body 스타일 변경 제거 — 이펙트+클린업으로 전환
handleScrollLock(isOpen)을 렌더에서 호출하면 리렌더마다 DOM을 건드립니다. 이펙트로 감싸고 언마운트 시 원복해 주세요.추가 수정(파일 상단 import):
🤖 Prompt for AI Agents