From 39bdf8b5c3e79e2c224db29f3c87d17135e2e0fb Mon Sep 17 00:00:00 2001 From: Fringg Date: Tue, 10 Mar 2026 07:39:04 +0300 Subject: [PATCH] fix: CopiedToast not visible due to CSS transform context Use createPortal to render toast at document.body level, escaping framer-motion's transform on the tab content wrapper. Remove unused useRef import and shareToastTapCopy i18n key. --- src/locales/en.json | 3 +- src/locales/ru.json | 3 +- src/pages/GiftSubscription.tsx | 53 +++++++++++++--------------------- 3 files changed, 22 insertions(+), 37 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 366ac88..01e7144 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -4249,7 +4249,6 @@ "shareModalActivateVia": "Activate via bot:", "shareModalActivateViaCabinet": "Or via website:", "copyMessage": "Copy message", - "shareToastCopied": "Message copied", - "shareToastTapCopy": "tap to copy again" + "shareToastCopied": "Message copied" } } diff --git a/src/locales/ru.json b/src/locales/ru.json index 292c6ac..3ad196b 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -4816,7 +4816,6 @@ "shareModalActivateVia": "Активировать через бота:", "shareModalActivateViaCabinet": "Или через сайт:", "copyMessage": "Скопировать сообщение", - "shareToastCopied": "Сообщение скопировано", - "shareToastTapCopy": "нажмите чтобы скопировать ещё раз" + "shareToastCopied": "Сообщение скопировано" } } diff --git a/src/pages/GiftSubscription.tsx b/src/pages/GiftSubscription.tsx index ce4cc91..54bbc4e 100644 --- a/src/pages/GiftSubscription.tsx +++ b/src/pages/GiftSubscription.tsx @@ -1,4 +1,5 @@ -import { useState, useMemo, useEffect, useCallback, useRef } from 'react'; +import { useState, useMemo, useEffect, useCallback } from 'react'; +import { createPortal } from 'react-dom'; import { useNavigate, useSearchParams, Link } from 'react-router'; import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { useTranslation } from 'react-i18next'; @@ -953,43 +954,26 @@ function ActivateTabContent({ initialCode }: { initialCode?: string | null }) { // Sub-components: My Gifts Tab // ============================================================ -function ShareToast({ message, onDismiss }: { message: string; onDismiss: () => void }) { +function CopiedToast({ onDismiss }: { onDismiss: () => void }) { const { t } = useTranslation(); - const timerRef = useRef>(undefined); useEffect(() => { - timerRef.current = setTimeout(onDismiss, 5000); - return () => { - if (timerRef.current) clearTimeout(timerRef.current); - }; + const timer = setTimeout(onDismiss, 2000); + return () => clearTimeout(timer); }, [onDismiss]); - const handleClick = useCallback(async () => { - await copyToClipboard(message); - if (timerRef.current) clearTimeout(timerRef.current); - timerRef.current = setTimeout(onDismiss, 2000); - }, [message, onDismiss]); - return ( - +
+ + {t('gift.shareToastCopied')} +
); } @@ -1095,10 +1079,13 @@ function SentGiftCard({ gift }: { gift: SentGift }) {

)} - {/* Share toast */} - - {showToast && } - + {/* Copied toast — portal to escape motion.div transform context */} + {createPortal( + + {showToast && } + , + document.body, + )} ); }