Stu Mason
Stu Mason

Activity

StuMason/cleanconnect
TidyLinker.com
TypeScript
Pull Request Merged

PR #178 merged: fix: don't close DatePicker when onSelect fires with undefined

PR #177 was squash-merged before I pushed these follow-up commits. They never made it to main. This PR carries them onto latest main as a clean stack.

Why this is still broken on prod despite #177 merging

#177 fixed layer 1 (booking-dialog stopped unmounting the entire DatePicker during availability fetch). Local re-testing with a seeded availability cleaner exposed a second layer: the inner Calendar (rdp-root) was still being remounted twice during the parent re-render, and react-day-picker fires onSelect(undefined) during reconciliation. My handleSelect always called setIsOpen(false), treating spurious undefined the same as a real pick. So even with #177 deployed, the calendar still closes after clicking >.

The range picker already had the guard (if (range?.from && range?.to)); the single picker didn't.

What's in here

  1. date-picker.tsxhandleSelect only closes when a concrete date is selected. Matches the range picker.
  2. DevelopmentSeeder.php — give [email protected] a Mon–Fri 09:00–17:00 availability schedule. The booking dialog's hasAvailability !== false branch was dormant locally because no demo cleaner had slots configured — that's how we shipped the unmount bug in PR #176 and how the first fix attempt passed a local smoke test that didn't exercise the bugged code path.
  3. docs/standards/frontend.md — two new "Never do this" rules under UI Components, capturing the post-mortem lessons:
    • Never unmount a stateful component during async loading (the booking-dialog antipattern)
    • Don't auto-close popovers on every onSelect (the spurious-undefined case)

Verified locally

[email protected] now has M–F 9–5 availability. Booking dialog shows the Select dropdown (hasAvailability !== false branch), identical to prod Kenneth.

  • Click Preferred date → calendar opens
  • Click > → May → June, calendar persists
  • Click > again → June → July, calendar persists
  • Two consecutive month changes without dismissal

Screenshot: scratch/datepicker-next-month-FIXED.png.

Post-mortem in PR #177 body covers the full sequence

This PR is the mechanical "ship what didn't make it" follow-up. The why/how is in #177's description.

+68
additions
-1
deletions
3
files changed