Fix modal scroll shift: add width:100% to body lock

This commit is contained in:
2026-05-29 14:59:33 +03:00
parent 466cb97a4e
commit f043107f87

View File

@@ -35,17 +35,19 @@ export default function CatModal({ catId, onClose }: CatModalProps) {
useEffect(() => { if (data?.cat) setLikeCount(data.cat.likes_count); }, [data]); useEffect(() => { if (data?.cat) setLikeCount(data.cat.likes_count); }, [data]);
useEffect(() => { useEffect(() => {
const scrollY = window.scrollY; const scrollY = window.scrollY;
document.body.style.overflow = 'hidden';
document.body.style.position = 'fixed'; document.body.style.position = 'fixed';
document.body.style.top = `-${scrollY}px`; document.body.style.top = `-${scrollY}px`;
document.body.style.left = '0'; document.body.style.left = '0';
document.body.style.right = '0'; document.body.style.right = '0';
document.body.style.overflow = 'hidden'; document.body.style.width = '100%';
return () => { return () => {
document.body.style.overflow = '';
document.body.style.position = ''; document.body.style.position = '';
document.body.style.top = ''; document.body.style.top = '';
document.body.style.left = ''; document.body.style.left = '';
document.body.style.right = ''; document.body.style.right = '';
document.body.style.overflow = ''; document.body.style.width = '';
window.scrollTo(0, scrollY); window.scrollTo(0, scrollY);
}; };
}, []); }, []);