We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3692373 commit 6b02badCopy full SHA for 6b02bad
1 file changed
src/@next/Modal/Modal.tsx
@@ -58,13 +58,21 @@ export const Modal = React.forwardRef<HTMLDivElement, ModalProps>(
58
ref
59
) {
60
useEffect(() => {
61
+ if (typeof window === 'undefined' || !window.document) return;
62
+
63
+ const enableScroll = () => {
64
+ document.body.style.overflow = 'unset';
65
+ };
66
67
if (isOpen) {
- if (typeof window != 'undefined' && window.document) {
- document.body.style.overflow = 'hidden';
- }
68
+ document.body.style.overflow = 'hidden';
69
} else {
- document.body.style.overflow = 'unset';
70
+ enableScroll();
71
}
72
73
+ return () => {
74
75
76
}, [isOpen]);
77
78
if (!isOpen) {
0 commit comments