From 84a9781a03dd0960841f1538146d6ddbf96e5bce Mon Sep 17 00:00:00 2001 From: highperfocused Date: Sun, 6 Sep 2026 21:34:28 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20address=20Copilot=20review=20=E2=80=94?= =?UTF-8?q?=20keyboard=20trap,=20midnight=20formatting,=20nprofile=20hint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - MonthGrid: exactly one gridcell must stay tab-focusable. When no day is selected and the displayed month doesn't contain today (e.g. after a PageUp/PageDown jump), every cell previously got tabIndex=-1, trapping keyboard users out of the grid. Falls back to the 1st of the month. - calendarEvents: formatEventTimeRange treated `end` as inclusive when checking same-day, so a time-based event ending exactly at local midnight formatted as a cross-day range even though eventDateKeys() attributes it to the start day only. Now compares against end-1ms, consistent with eventDateKeys(). - CalendarFilters: the author placeholder/error text only mentioned npub/hex even though nprofile is accepted (resolveAuthorInput handles it) — updated both to mention all three. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01BYiUtZMQeA5RHggQw73wto --- src/apps/calendar/CalendarFilters.tsx | 4 ++-- src/apps/calendar/MonthGrid.tsx | 9 ++++++++- src/lib/calendarEvents.test.ts | 21 +++++++++++++++++++++ src/lib/calendarEvents.ts | 8 ++++++-- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/apps/calendar/CalendarFilters.tsx b/src/apps/calendar/CalendarFilters.tsx index 66eb513..edf9db7 100644 --- a/src/apps/calendar/CalendarFilters.tsx +++ b/src/apps/calendar/CalendarFilters.tsx @@ -80,13 +80,13 @@ export function CalendarFilters({ filters, onChange, authorError, resolvedAuthor set('authorInput', event.target.value)} aria-invalid={authorError || undefined} className="h-8 text-xs" /> - {authorError &&

Not a valid npub or hex pubkey.

} + {authorError &&

Not a valid npub, nprofile, or hex pubkey.

}
diff --git a/src/apps/calendar/MonthGrid.tsx b/src/apps/calendar/MonthGrid.tsx index ef61f9d..7009242 100644 --- a/src/apps/calendar/MonthGrid.tsx +++ b/src/apps/calendar/MonthGrid.tsx @@ -48,6 +48,13 @@ export function MonthGrid({ const todayKey = localDateKey(today); const cellRefs = useRef(new Map()); + // Exactly one cell must be tab-focusable, or a keyboard user who tabs away + // and back can never re-enter the grid. Prefer the selected day, then + // today if it's in the displayed month, and only otherwise fall back to + // the 1st — e.g. after PageUp/PageDown lands on a month with neither. + const isTodayInMonth = today.getFullYear() === monthAnchor.getFullYear() && today.getMonth() === monthIndex; + const focusKey = selectedDate ?? (isTodayInMonth ? todayKey : localDateKey(new Date(monthAnchor.getFullYear(), monthIndex, 1))); + const focusDate = (date: Date) => { const key = localDateKey(date); onSelectDate(key, { focus: true }); @@ -121,7 +128,7 @@ export function MonthGrid({ const isCurrentMonth = date.getMonth() === monthIndex; const isToday = key === todayKey; const isSelected = key === selectedDate; - const isFocusable = selectedDate ? isSelected : isToday && isCurrentMonth; + const isFocusable = key === focusKey; return (