diff --git a/src/components/ConnectionModal.tsx b/src/components/ConnectionModal.tsx index a5a0b45..6d13dbe 100644 --- a/src/components/ConnectionModal.tsx +++ b/src/components/ConnectionModal.tsx @@ -1,4 +1,5 @@ import { useState, useMemo, useEffect } from 'react' +import { createPortal } from 'react-dom' import { useTranslation } from 'react-i18next' import { useQuery } from '@tanstack/react-query' import { subscriptionApi } from '../api/subscription' @@ -133,7 +134,6 @@ export default function ConnectionModal({ onClose }: ConnectionModalProps) { const isMobileScreen = useIsMobile() const isMobile = isMobileScreen || isTelegramWebApp - const safeTop = isTelegramWebApp ? Math.max(safeAreaInset.top, contentSafeAreaInset.top) : 0 const safeBottom = isTelegramWebApp ? Math.max(safeAreaInset.bottom, contentSafeAreaInset.bottom) : 0 const { data: appConfig, isLoading, error } = useQuery({ @@ -216,30 +216,36 @@ export default function ConnectionModal({ onClose }: ConnectionModalProps) { ) // Mobile fullscreen wrapper - like React Native Modal with animationType="slide" - const MobileWrapper = ({ children }: { children: React.ReactNode }) => ( - <> - {/* Backdrop */} -
- {/* Modal - slides from bottom */} -
- {/* Close button */} - - {children} -
- - ) + {/* Close button */} + + {children} +
+ + ) + + if (typeof document !== 'undefined') { + return createPortal(content, document.body) + } + return content + } const Wrapper = isMobile ? MobileWrapper : DesktopWrapper diff --git a/src/components/TopUpModal.tsx b/src/components/TopUpModal.tsx index bbcacdc..14f42d4 100644 --- a/src/components/TopUpModal.tsx +++ b/src/components/TopUpModal.tsx @@ -1,4 +1,5 @@ import { useState, useRef, useEffect } from 'react' +import { createPortal } from 'react-dom' import { useTranslation } from 'react-i18next' import { useMutation } from '@tanstack/react-query' import { balanceApi } from '../api/balance' @@ -169,11 +170,10 @@ export default function TopUpModal({ method, onClose, initialAmountRubles }: Top return () => clearTimeout(timer) }, []) - return ( + const modalContent = (
) + + if (typeof document !== 'undefined') { + return createPortal(modalContent, document.body) + } + return modalContent }