prevent bg scroll while modal open

This commit is contained in:
Martti Malmi 2023-07-06 08:43:52 +03:00
parent 0ed41b4957
commit c04b8a24f9

View File

@ -61,8 +61,10 @@ const Modal: FC<Props> = ({
};
useEffect(() => {
document.body.style.overflow = 'hidden';
window.addEventListener('keydown', handleKeyDown);
return () => {
document.body.style.overflow = 'unset';
window.removeEventListener('keydown', handleKeyDown);
};
}, [handleKeyDown]);