diff --git a/src/components/ConnectionModal.tsx b/src/components/ConnectionModal.tsx index ae7d8bf..c6d62a2 100644 --- a/src/components/ConnectionModal.tsx +++ b/src/components/ConnectionModal.tsx @@ -215,12 +215,36 @@ export default function ConnectionModal({ onClose }: ConnectionModalProps) { setDetectedPlatform(detectPlatform()) }, []) - // Lock body scroll when modal is open + // Lock body scroll when modal is open (works on iOS too) useEffect(() => { - const originalStyle = window.getComputedStyle(document.body).overflow - document.body.style.overflow = 'hidden' + const scrollY = window.scrollY + const body = document.body + const html = document.documentElement + + // Save original styles + const originalBodyOverflow = body.style.overflow + const originalBodyPosition = body.style.position + const originalBodyTop = body.style.top + const originalBodyWidth = body.style.width + const originalHtmlOverflow = html.style.overflow + + // Lock scroll + body.style.overflow = 'hidden' + body.style.position = 'fixed' + body.style.top = `-${scrollY}px` + body.style.width = '100%' + html.style.overflow = 'hidden' + return () => { - document.body.style.overflow = originalStyle + // Restore original styles + body.style.overflow = originalBodyOverflow + body.style.position = originalBodyPosition + body.style.top = originalBodyTop + body.style.width = originalBodyWidth + html.style.overflow = originalHtmlOverflow + + // Restore scroll position + window.scrollTo(0, scrollY) } }, []) @@ -295,16 +319,18 @@ export default function ConnectionModal({ onClose }: ConnectionModalProps) { // Modal wrapper - centered on desktop, top on mobile const ModalWrapper = ({ children }: { children: React.ReactNode }) => (
e.stopPropagation()} > {children}