fix: clear date selection when clicking an unavailable/closed day
bits-ui blocks onValueChange for unavailable dates, leaving stale selection. Adds native click detection on [data-unavailable] elements to call onchange(undefined) so the time picker hides and the user knows nothing was picked.
This commit is contained in:
@@ -485,6 +485,21 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Clear selection when navigating to a month that doesn't contain the selected date.
|
||||
// Runs AFTER all synchronous state changes settle, so clicking a date in a different
|
||||
// month (fires both onPlaceholderChange and onValueChange) keeps the new selection,
|
||||
// while clicking prev/next arrows without picking a date clears it.
|
||||
$effect(() => {
|
||||
if (
|
||||
newDate &&
|
||||
placeholderDate &&
|
||||
(newDate.month !== placeholderDate.month || newDate.year !== placeholderDate.year)
|
||||
) {
|
||||
newDate = undefined;
|
||||
newTime = '';
|
||||
}
|
||||
});
|
||||
|
||||
// ─── API calls ──────────────────────────────────────────
|
||||
async function fetchHoursRange(startDate: CalendarDate, months: number) {
|
||||
loadingHours = true;
|
||||
|
||||
Reference in New Issue
Block a user