From c8fead40345822d00b55b46a66afdbe3299831a0 Mon Sep 17 00:00:00 2001 From: poignatov Date: Sun, 8 Mar 2026 19:25:35 +0300 Subject: [PATCH] =?UTF-8?q?6.4.2:=20=D0=97=D0=B0=D0=BA=D1=80=D1=8B=D1=82?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B4=D0=B8=D0=B0=D0=BB=D0=BE=D0=B3=D0=BE=D0=B2?= =?UTF-8?q?=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=BE=D0=B9=20=D0=BD=D0=B0?= =?UTF-8?q?=D0=B7=D0=B0=D0=B4=20(=D1=82=D0=BE=D0=B2=D0=B0=D1=80=D1=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VERSION | 2 +- play-life-web/package.json | 2 +- .../src/components/ShoppingItemForm.css | 3 +- .../src/components/ShoppingItemForm.jsx | 2 +- play-life-web/src/components/ShoppingList.jsx | 76 ++++++++++++++++++- 5 files changed, 77 insertions(+), 8 deletions(-) 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}