6.4.11: Фикс кнопки назад для диалога желания
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m6s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m6s
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "play-life-web",
|
||||
"version": "6.4.10",
|
||||
"version": "6.4.11",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -242,8 +242,10 @@ function WishlistDetail({ wishlistId, onNavigate, onRefresh, boardId, onClose, p
|
||||
|
||||
// Закрываем модальные окна
|
||||
historyPushedForTaskRef.current = false
|
||||
selectedTaskForDetailRef.current = null
|
||||
setSelectedTaskForDetail(null)
|
||||
historyPushedForWishlistRef.current = false
|
||||
wishlistIdRef.current = null
|
||||
|
||||
// Закрываем экран желания через onClose
|
||||
// Навигация на task-form уже происходит в TaskDetail, поэтому не вызываем onNavigate здесь
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user