fix: hide Telegram back button on bottom nav pages

Back button was showing on all non-root routes including top-level
pages reachable from the bottom navigation menu (subscription, balance,
referral, support, wheel). These pages don't need a back button since
users navigate between them via the bottom tab bar.
This commit is contained in:
c0mrade
2026-02-09 10:48:25 +03:00
parent 0389acdf83
commit e5ed6d0401

View File

@@ -20,6 +20,9 @@ import { isInTelegramWebApp } from './hooks/useTelegramSDK';
* Manages Telegram BackButton visibility based on navigation location. * Manages Telegram BackButton visibility based on navigation location.
* Shows back button on non-root routes, hides on root. * Shows back button on non-root routes, hides on root.
*/ */
/** Pages reachable from bottom nav — treat as top-level (no back button). */
const BOTTOM_NAV_PATHS = ['/', '/subscription', '/balance', '/referral', '/support', '/wheel'];
function TelegramBackButton() { function TelegramBackButton() {
const location = useLocation(); const location = useLocation();
const navigate = useNavigate(); const navigate = useNavigate();
@@ -27,9 +30,9 @@ function TelegramBackButton() {
navigateRef.current = navigate; navigateRef.current = navigate;
useEffect(() => { useEffect(() => {
const isRoot = location.pathname === '/' || location.pathname === ''; const isTopLevel = location.pathname === '' || BOTTOM_NAV_PATHS.includes(location.pathname);
try { try {
if (isRoot) { if (isTopLevel) {
hideBackButton(); hideBackButton();
} else { } else {
showBackButton(); showBackButton();