From 1bf7f3d8fbf84f12fb43c2c47f045367110f92ad Mon Sep 17 00:00:00 2001 From: Aleix Soler Date: Thu, 19 Mar 2026 12:51:47 +0100 Subject: [PATCH] feat(modals): auto-select the active status template tab when opening status selector --- .../ChangeStatusModal/StatusSelectorGroup.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/components/ChangeStatusModal/StatusSelectorGroup.tsx b/components/ChangeStatusModal/StatusSelectorGroup.tsx index 52b4767..3792976 100644 --- a/components/ChangeStatusModal/StatusSelectorGroup.tsx +++ b/components/ChangeStatusModal/StatusSelectorGroup.tsx @@ -14,6 +14,7 @@ export interface Props { templates: StatusTemplate[]; iconFrameMode: "always" | "never"; iconColorMode: "status" | "theme"; + activeStatus?: NoteStatus; onSelectedState: ( frontmatterTagName: string, status: NoteStatus, @@ -28,6 +29,7 @@ export const StatusSelectorGroup: React.FC = ({ frontmatterTagName, iconFrameMode, iconColorMode, + activeStatus, onSelectedState, }) => { const TEMPLATE_ALL_VIEW = "__all__"; @@ -114,8 +116,21 @@ export const StatusSelectorGroup: React.FC = ({ return views; }, [availableStatuses, templates]); - const [selectedTemplateId, setSelectedTemplateId] = - useState(TEMPLATE_ALL_VIEW); + const [selectedTemplateId, setSelectedTemplateId] = useState(() => { + if (activeStatus && activeStatus.templateId) { + return activeStatus.templateId; + } + if (currentStatuses && currentStatuses.length > 0) { + const statusWithTemplate = currentStatuses.find( + (s) => s.templateId, + ); + if (statusWithTemplate) { + return statusWithTemplate.templateId as string; + } + return TEMPLATE_CUSTOM_VIEW; + } + return TEMPLATE_ALL_VIEW; + }); useEffect(() => { const exists = templateViewOptions.some(