Skip to content

fix: resolve tag removal bug - tags can now be properly added/removed#32

Merged
brianorwhatever merged 1 commit intomainfrom
fix/tag-removal-bug
Feb 7, 2026
Merged

fix: resolve tag removal bug - tags can now be properly added/removed#32
brianorwhatever merged 1 commit intomainfrom
fix/tag-removal-bug

Conversation

@krusty-agent
Copy link
Collaborator

Bug Fixed

Issue: "Can't remove tags and they seem to be on every item"

Root Cause

The ItemDetailsModal was receiving stale item snapshots stored in React state. When tags were updated on the server via mutations, the modal still showed the old item.tags data because it was using a snapshot instead of live query data.

Before (broken flow):

  1. User opens item modal → setEditingItem(item) stores a snapshot
  2. User clicks tag to add/remove → mutation runs on server
  3. Server updates item.tags
  4. items array from useQuery updates (reactive)
  5. BUT: editingItem in React state is still the old snapshot
  6. Modal shows stale tags, making it seem like tags can't be removed

Fix

  • Changed editingItem and selectedCalendarItem state from Doc<"items"> | null to Id<"items"> | null
  • Look up live items from the reactive items array using useMemo
  • Modal now receives real-time updates from Convex queries

After (fixed flow):

  1. User opens modal → setEditingItemId(item._id) stores only the ID
  2. User clicks tag → mutation runs
  3. Server updates item.tags
  4. items array from useQuery updates
  5. editingItem useMemo recalculates with live data
  6. Modal shows current tags ✅

Testing

  • Build passes ✅
  • Tag addition works
  • Tag removal works
  • Tags correctly show per-item (not shared across items)

Bug: Tags couldn't be removed and appeared on every item.

Root cause: ItemDetailsModal received stale item snapshots stored in
React state. When tags were updated on the server, the modal still
showed the old data because it was using a snapshot instead of the
live query data.

Fix:
- Store only item IDs in state (editingItemId, selectedCalendarItemId)
- Look up live items from the reactive items array using useMemo
- This ensures tag changes are immediately reflected in the modal UI

The modal now receives real-time updates from Convex queries, so
tag additions/removals are properly reflected in the UI.
@brianorwhatever brianorwhatever merged commit 8d1d5e0 into main Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants