diff --git a/src/components/QuickEntry.tsx b/src/components/QuickEntry.tsx index 61cdd35..c9e3b81 100644 --- a/src/components/QuickEntry.tsx +++ b/src/components/QuickEntry.tsx @@ -9,6 +9,8 @@ export const QuickEntry: Component = () => { const [isOpen, setIsOpen] = createSignal(false); // Autofill tags based on context when opening const initialTags = createMemo(() => { + if (!isOpen()) return []; + const tags: string[] = []; const ctx = currentTaskContext(); diff --git a/src/components/QuickEntryForm.tsx b/src/components/QuickEntryForm.tsx index 23eeed8..369da8d 100644 --- a/src/components/QuickEntryForm.tsx +++ b/src/components/QuickEntryForm.tsx @@ -44,23 +44,18 @@ export const QuickEntryForm: Component = (props) => { }); // Reactive sync from props (handles context changes while open) - let lastInitialTags: string[] = []; createEffect(() => { const initial = props.initialTags || []; - - setTags(prev => { - // 1. Identify context tags that were removed - const removed = lastInitialTags.filter(t => !initial.includes(t)); - // 2. Filter them out of the current tag list - let next = prev.filter(t => !removed.includes(t)); - // 3. Add new context tags that aren't already present - initial.forEach(t => { - if (!next.includes(t)) next.push(t); + if (initial.length > 0) { + setTags(prev => { + // Merge initial tags if not already present + const next = [...prev]; + initial.forEach(t => { + if (!next.includes(t)) next.push(t); + }); + return next; }); - return next; - }); - - lastInitialTags = [...initial]; + } }); // Reactive shorthand parsing