From e845400fca664ce3b47ad1b3570525ffbdfde36c Mon Sep 17 00:00:00 2001 From: BOHA Date: Sat, 6 Jun 2026 01:17:23 +0200 Subject: [PATCH] fix(plan): keep retired category usable when editing an entry's note Update validates the category only when it changes, so a note-only edit on an entry whose category was later hidden/deleted no longer 400s. The edit select also shows the current (retired) category marked '(skryta)' instead of silently snapping to the first active option; create defaults to an active category. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/admin/components/PlanCellModal.tsx | 19 ++++++++++++++++++- src/services/plan.service.ts | 7 +++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/admin/components/PlanCellModal.tsx b/src/admin/components/PlanCellModal.tsx index e910f59..bad9f29 100644 --- a/src/admin/components/PlanCellModal.tsx +++ b/src/admin/components/PlanCellModal.tsx @@ -122,7 +122,11 @@ function EditForm(props: Props) { date_to: mode.date, is_range: false, project_id: null as number | null, - category: "work", + // Default to "work" when it's active, otherwise the first active + // category, so a new entry never starts on a retired key. + category: activeCategories.some((c) => c.key === "work") + ? "work" + : (activeCategories[0]?.key ?? "work"), note: "", }; } @@ -294,6 +298,19 @@ function EditForm(props: Props) { value={category} onChange={(e) => setCategory(e.target.value)} > + {/* If the row's current category was retired/hidden, still show it + (marked) so the select reflects reality instead of silently + snapping to the first active option. The server only re-checks + the category if it changes, so keeping it saves fine. */} + {category && !activeCategories.some((c) => c.key === category) && ( + + )} {activeCategories.map((c) => (