Fix issues from QA review: stale closure, aria-labels, mobile sheet close
W-01: Use functional updater in handleDayClick to remove displayedMonth
from dependency array, eliminating stale closure risk
S-02: Add aria-label with full date string to day buttons for screen readers
S-04: Close mobile sidebar sheet when clicking a date in mini calendar,
matching existing onUseTemplate behavior
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
68337b12a0
commit
0ba920f8e1
@ -613,7 +613,7 @@ export default function CalendarPage() {
|
||||
<Sheet open={mobileSidebarOpen} onOpenChange={setMobileSidebarOpen}>
|
||||
<SheetContent className="w-72 p-0">
|
||||
<SheetClose onClick={() => setMobileSidebarOpen(false)} />
|
||||
<CalendarSidebar onUseTemplate={(tmpl) => { setMobileSidebarOpen(false); handleUseTemplate(tmpl); }} onSharedVisibilityChange={setVisibleSharedIds} width={288} onDateClick={handleMiniCalClick} currentDate={currentDate} firstDayOfWeek={firstDayOfWeek} navKey={navKey} />
|
||||
<CalendarSidebar onUseTemplate={(tmpl) => { setMobileSidebarOpen(false); handleUseTemplate(tmpl); }} onSharedVisibilityChange={setVisibleSharedIds} width={288} onDateClick={(dateStr) => { setMobileSidebarOpen(false); handleMiniCalClick(dateStr); }} currentDate={currentDate} firstDayOfWeek={firstDayOfWeek} navKey={navKey} />
|
||||
</SheetContent>
|
||||
</Sheet>
|
||||
)}
|
||||
|
||||
@ -77,12 +77,9 @@ const MiniCalendar = memo(function MiniCalendar({
|
||||
const handleDayClick = useCallback((day: Date) => {
|
||||
const dateStr = format(day, 'yyyy-MM-dd');
|
||||
setSelectedDate(dateStr);
|
||||
// If clicking a day in another month, also shift the displayed month
|
||||
if (!isSameMonth(day, displayedMonth)) {
|
||||
setDisplayedMonth(startOfMonth(day));
|
||||
}
|
||||
setDisplayedMonth((prev) => isSameMonth(day, prev) ? prev : startOfMonth(day));
|
||||
onDateClick(dateStr);
|
||||
}, [displayedMonth, onDateClick]);
|
||||
}, [onDateClick]);
|
||||
|
||||
const selectedDateObj = useMemo(
|
||||
() => selectedDate ? parseDate(selectedDate) : null,
|
||||
@ -137,6 +134,7 @@ const MiniCalendar = memo(function MiniCalendar({
|
||||
<button
|
||||
key={format(day, 'yyyy-MM-dd')}
|
||||
type="button"
|
||||
aria-label={format(day, 'EEEE, MMMM d, yyyy')}
|
||||
onClick={() => handleDayClick(day)}
|
||||
className={[
|
||||
'h-7 text-xs flex items-center justify-center rounded-md transition-colors duration-100',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user