fix: snap initial preSelection to first enabled day in month#6288
Closed
GauravDhuri wants to merge 1 commit into
Closed
fix: snap initial preSelection to first enabled day in month#6288GauravDhuri wants to merge 1 commit into
GauravDhuri wants to merge 1 commit into
Conversation
When openToDate (or the bounded default) lands on a disabled day - such as a gap between includedDates - preSelection became a disabled date, leaving no day with tabindex="0" in the grid. This breaks keyboard and screen-reader navigation, as there is no focusable day to enter the calendar. calcInitialState now snaps the bounded preSelection to the first enabled day in its month, reusing a new shared getEnabledDateInMonth util. The same logic already backed month navigation (Calendar.getEnabledPreSelectionDateForMonth), which is refactored to use the shared util so both paths stay consistent. Fixes Hacker0x01#6286
d6e3212 to
eeb47d8
Compare
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.
name: Pull Request
about: Create a pull request to improve this repository
title: ""
labels: ""
assignees: ""
Description
Linked issue: #6286
Problem
When openToDate (or the bounded default preselection) falls on a day that isn't selectable. For example gap between
includeDates, or a day removed byexcludeDates/filterDate.. the calendar opens with no focusable day. The rovingtabindex="0"is only applied to the pre-selected day when that day is enabled (Day.isKeyboardSelected), so when the preselection is disabled, no day in the grid is reachable. Keyboard and screen-reader users cannot move into the calendar at all.Month navigation already guarded against this via
Calendar.getEnabledPreSelectionDateForMonth, but the initial open path incalcInitialStatedid not, so the bug appared whenever the calendar first opened onto a disabled day.Changes
getEnabledDateInMonth (date, options)util indate_utils.ts: returns the date if its enabled, otherwise the first enabled day in that month ornullif the month has none.calcInitialStatenow snaps the bounded preselection through this util, keeping the initial open and month navigation paths consistentgetEnabledDateInMonthand integration coverage asserting a focusable day exists whenopenToDatelands on a gap.Screenshots
To reviewers
Contribution checklist