diff --git a/VERSION b/VERSION index b03e20c..e5a66ba 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.4.10 +6.4.11 diff --git a/play-life-web/package.json b/play-life-web/package.json index 949ea43..70181d7 100644 --- a/play-life-web/package.json +++ b/play-life-web/package.json @@ -1,6 +1,6 @@ { "name": "play-life-web", - "version": "6.4.10", + "version": "6.4.11", "type": "module", "scripts": { "dev": "vite", diff --git a/play-life-web/src/App.jsx b/play-life-web/src/App.jsx index 4d2f98e..e91b05b 100644 --- a/play-life-web/src/App.jsx +++ b/play-life-web/src/App.jsx @@ -778,7 +778,7 @@ function AppContent() { if (taskDetailModal || wishlistDetailModal) { return } - + // Если это модальное окно, не обрабатываем здесь - компоненты сами закроют его if (event.state && event.state.modalOpen) { // Если модальных окон нет в DOM, это устаревшая запись — пропускаем её diff --git a/play-life-web/src/components/WishlistDetail.jsx b/play-life-web/src/components/WishlistDetail.jsx index 333dd9a..6e4f882 100644 --- a/play-life-web/src/components/WishlistDetail.jsx +++ b/play-life-web/src/components/WishlistDetail.jsx @@ -239,12 +239,14 @@ function WishlistDetail({ wishlistId, onNavigate, onRefresh, boardId, onClose, p if (skipHistoryBack === true) { // Сохраняем флаг перед сбросом const hadWishlistHistory = historyPushedForWishlistRef.current - + // Закрываем модальные окна historyPushedForTaskRef.current = false + selectedTaskForDetailRef.current = null setSelectedTaskForDetail(null) historyPushedForWishlistRef.current = false - + wishlistIdRef.current = null + // Закрываем экран желания через onClose // Навигация на task-form уже происходит в TaskDetail, поэтому не вызываем onNavigate здесь // App.jsx обработает навигацию и заменит запись task-detail на task-form через replaceState @@ -255,6 +257,7 @@ function WishlistDetail({ wishlistId, onNavigate, onRefresh, boardId, onClose, p window.history.back() } else { historyPushedForTaskRef.current = false + selectedTaskForDetailRef.current = null setSelectedTaskForDetail(null) } } @@ -291,28 +294,24 @@ function WishlistDetail({ wishlistId, onNavigate, onRefresh, boardId, onClose, p if (!wishlistId && !selectedTaskForDetail) return const handlePopState = (event) => { - // Проверяем наличие модальных окон в DOM - const taskDetailModal = document.querySelector('.task-detail-modal-overlay') - const wishlistDetailModal = document.querySelector('.wishlist-detail-modal-overlay') - // Используем refs для получения актуального состояния + // (refs обновляются сразу в обработчике, в отличие от DOM который обновляется после рендера) const currentTaskDetail = selectedTaskForDetailRef.current const currentWishlistId = wishlistIdRef.current - // Сначала проверяем вложенное модальное окно TaskDetail - if (currentTaskDetail || taskDetailModal) { + if (currentTaskDetail) { setSelectedTaskForDetail(null) + selectedTaskForDetailRef.current = null historyPushedForTaskRef.current = false - // Возвращаем запись для WishlistDetail - if (currentWishlistId || wishlistDetailModal) { - window.history.pushState({ modalOpen: true, type: 'wishlist-detail' }, '', window.location.href) - } + // НЕ пушим запись для WishlistDetail — оригинальная запись wishlist-detail + // уже находится на текущей позиции в history stack (мы вернулись на неё после back). + // Следующий back от wishlist-detail закроет диалог желания. return } // Если открыто модальное окно WishlistDetail, закрываем его - if (currentWishlistId || wishlistDetailModal) { + if (currentWishlistId) { if (onClose) { onClose() } else { @@ -330,9 +329,11 @@ function WishlistDetail({ wishlistId, onNavigate, onRefresh, boardId, onClose, p } } historyPushedForWishlistRef.current = false + wishlistIdRef.current = null // Следующее нажатие "назад" обработается App.jsx нормально return } + } window.addEventListener('popstate', handlePopState)