Skip to content

Commit 0ca67b8

Browse files
committed
unroll scroll lock logic
1 parent cbff77d commit 0ca67b8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

app/ui/modal.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,21 @@ function useModalBehaviour(onClose: () => void) {
2020
useEffect(() => {
2121
const prev = document.documentElement.style.overflow;
2222
document.documentElement.style.overflow = 'hidden';
23-
return () => (document.documentElement.style.overflow = prev);
23+
return () => {
24+
document.documentElement.style.overflow = prev;
25+
};
2426
}, []);
2527

2628
useEffect(() => {
27-
const h = (e: KeyboardEvent) => e.key === 'Escape' && onClose();
29+
const h = (e: KeyboardEvent) => {
30+
if (e.key === 'Escape') {
31+
onClose();
32+
}
33+
};
2834
window.addEventListener('keydown', h);
29-
return () => window.removeEventListener('keydown', h);
35+
return () => {
36+
window.removeEventListener('keydown', h);
37+
};
3038
}, [onClose]);
3139
}
3240

0 commit comments

Comments
 (0)