diff --git a/VERSION b/VERSION index 4c77920..a4c853e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.4.1 +6.4.2 diff --git a/play-life-web/package.json b/play-life-web/package.json index 91019d3..878bd92 100644 --- a/play-life-web/package.json +++ b/play-life-web/package.json @@ -1,6 +1,6 @@ { "name": "play-life-web", - "version": "6.4.1", + "version": "6.4.2", "type": "module", "scripts": { "dev": "vite", diff --git a/play-life-web/src/components/ShoppingItemForm.css b/play-life-web/src/components/ShoppingItemForm.css index 25e9879..f445437 100644 --- a/play-life-web/src/components/ShoppingItemForm.css +++ b/play-life-web/src/components/ShoppingItemForm.css @@ -13,7 +13,6 @@ } .shopping-item-form .repetition-label { - color: #64748b; - font-size: 0.875rem; + font-size: 1rem; white-space: nowrap; } diff --git a/play-life-web/src/components/ShoppingItemForm.jsx b/play-life-web/src/components/ShoppingItemForm.jsx index 5e21b5b..dca910c 100644 --- a/play-life-web/src/components/ShoppingItemForm.jsx +++ b/play-life-web/src/components/ShoppingItemForm.jsx @@ -235,7 +235,7 @@ function ShoppingItemForm({ onNavigate, itemId, boardId, onSaved }) {
- Через + Хватает на { setSelectedBoardIdState(boardId) try { @@ -250,6 +256,56 @@ function ShoppingList({ onNavigate, refreshTrigger = 0, isActive = false, initia } }, [initialBoardId]) + // Синхронизация refs для диалогов + useEffect(() => { + selectedItemForDetailRef.current = selectedItemForDetail + selectedItemForPostponeRef.current = selectedItemForPostpone + }, [selectedItemForDetail, selectedItemForPostpone]) + + // Закрытие диалогов кнопкой "Назад" (browser history API) + useEffect(() => { + if (selectedItemForPostpone && !historyPushedForPostponeRef.current) { + window.history.pushState({ modalOpen: true, type: 'shopping-postpone' }, '', window.location.href) + historyPushedForPostponeRef.current = true + } else if (!selectedItemForPostpone) { + historyPushedForPostponeRef.current = false + } + + if (selectedItemForDetail && !historyPushedForDetailRef.current) { + window.history.pushState({ modalOpen: true, type: 'shopping-detail' }, '', window.location.href) + historyPushedForDetailRef.current = true + } else if (!selectedItemForDetail) { + historyPushedForDetailRef.current = false + } + + if (!selectedItemForDetail && !selectedItemForPostpone) return + + const handlePopState = () => { + const currentDetail = selectedItemForDetailRef.current + const currentPostpone = selectedItemForPostponeRef.current + + if (currentPostpone) { + setSelectedItemForPostpone(null) + setPostponeDate('') + historyPushedForPostponeRef.current = false + if (currentDetail) { + window.history.pushState({ modalOpen: true, type: 'shopping-detail' }, '', window.location.href) + } + return + } + + if (currentDetail) { + setSelectedItemForDetail(null) + historyPushedForDetailRef.current = false + } + } + + window.addEventListener('popstate', handlePopState) + return () => { + window.removeEventListener('popstate', handlePopState) + } + }, [selectedItemForDetail, selectedItemForPostpone]) + // Фильтрация и группировка на клиенте const groupedItems = useMemo(() => { const now = new Date() @@ -319,10 +375,24 @@ function ShoppingList({ onNavigate, refreshTrigger = 0, isActive = false, initia if (selectedBoardId) fetchItems(selectedBoardId) } + const handleCloseDetail = () => { + if (historyPushedForDetailRef.current) { + window.history.back() + } else { + historyPushedForDetailRef.current = false + setSelectedItemForDetail(null) + } + } + // Модалка переноса const handlePostponeClose = () => { - setSelectedItemForPostpone(null) - setPostponeDate('') + if (historyPushedForPostponeRef.current) { + window.history.back() + } else { + historyPushedForPostponeRef.current = false + setSelectedItemForPostpone(null) + setPostponeDate('') + } } const handleDateSelect = (date) => { @@ -607,7 +677,7 @@ function ShoppingList({ onNavigate, refreshTrigger = 0, isActive = false, initia {selectedItemForDetail && ( setSelectedItemForDetail(null)} + onClose={handleCloseDetail} onRefresh={handleRefresh} onItemCompleted={() => setToast({ message: 'Товар выполнен', type: 'success' })} onNavigate={onNavigate}