Repository navigation
Closed
Description
Overview
Replace the $effect that watches selectedCalendarDate with a direct onchange handler on the Calendar component.
Problem Statement
Current implementation watches the calendar's bound value to detect selection:
// Lines 280-289 in base-node.svelte
$effect(() => {
if (selectedCalendarDate) {
const { year, month, day } = selectedCalendarDate;
const jsDate = new Date(year, month - 1, day);
handleDateSelection(jsDate);
selectedCalendarDate = undefined; // Reset for next selection
}
});This is watching for a value change to trigger an action - the definition of "effect as event handler". The Calendar component should have an onselect or onchange event we can use directly.
Proposed Solution
Use the Calendar's event callback instead of watching state:
<Calendar
type="single"
bind:value={selectedCalendarDate}
onValueChange={(date) => {
if (date) {
const { year, month, day } = date;
const jsDate = new Date(year, month - 1, day);
handleDateSelection(jsDate);
}
}}
/>Or if the shadcn Calendar doesn't have an event, wrap the selection logic in a controlled component pattern.
Acceptance Criteria
- Calendar selection handled via event callback, not
$effect - One
$effecteliminated from base-node.svelte - Date selection works identically (today, tomorrow, calendar picker)
- Date gets inserted into content correctly
- Code passes
bun run quality:fix - Tests pass (
bun run test:all)
Technical Specifications
Files to Modify
- base-node.svelte:
packages/desktop-app/src/lib/design/components/base-node.svelte- Lines 280-289
Calendar Component
- calendar.svelte:
packages/desktop-app/src/lib/components/ui/calendar/calendar.svelte - Check available props/events on the shadcn Calendar component
- May need to check bits-ui Calendar API for event callbacks
Migration Steps
- Check Calendar component API for
onValueChangeor similar - If available, use it directly
- If not, consider wrapping or modifying Calendar to emit event
- Remove the
$effectwatchingselectedCalendarDate
Testing Requirements
- Open autocomplete with
@ - Select "Select date..." option
- Click a date in calendar
- Verify date link inserted correctly
- Verify calendar closes after selection
Activity
malibio commentedon Nov 30, 2025
This issue is already complete in the current codebase. Analysis:
All acceptance criteria are met:
malibio commentedon Nov 30, 2025
Closing as already complete - all acceptance criteria met in current codebase.