fix: keep month grid keyboard tab stop after navigating to a shorter month#31
Merged
Conversation
…month The roving-tabindex active cell was tracked by a raw index that was never reconciled when the month changed. Months span 4-6 weeks, so navigating from a 6-week month to a shorter one could leave the stored index past the last cell, giving every cell tabIndex -1 and removing the grid's only keyboard tab stop. Clamp the active index to the current cell count so one cell always remains tabbable, and drive arrow-key movement from the clamped value. https://claude.ai/code/session_01RAQ7vWRxzEz4Ladq9PcxfN
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
🎉 This PR is included in version 1.0.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MonthViewuses a roving-tabindex pattern: one cell holdstabIndex={0}(the keyboard tab stop) and the rest holdtabIndex={-1}. The active cell was tracked by a rawfocusedIndexthat was never reconciled when the displayed month changed.Months render 4–6 weeks (28–42 cells). Navigating from a 6-week month with a late cell focused (e.g. index 40) to a 5-week month (35 cells) left
focusedIndexpointing past the last cell, so the comparisoncellIndex === focusedIndexmatched no cell. Every cell then hadtabIndex={-1}and the container istabIndex={-1}, so keyboard users could no longer Tab into the grid at all.Fix
activeIndex = Math.min(focusedIndex, totalCells - 1)so exactly one cell always keepstabIndex={0}.activeIndexfor the roving-tabindex comparison and as the base for arrow/Home/End movement, so navigation stays consistent after the index is clamped.No behavior change for same-month navigation; this only prevents the lost tab stop when the month length shrinks.
Test plan
pnpm run lint(tsc) — cleanpnpm run lint:eslint— cleanpnpm run test— 77 passed (2 new)tests/month-view-nav.test.tsx: verifies exactly one tabbable cell remains after navigating Aug 2026 (6 weeks) → Sep 2026 (5 weeks), and that arrow keys move the tab stop. Confirmed both tests fail without the fix (the tab-stop test reports 0 tabbable cells).https://claude.ai/code/session_01RAQ7vWRxzEz4Ladq9PcxfN
Generated by Claude Code