Skip to content

[useDateRangePickerState] Date ranges that cross unavailable dates do not trigger the invalid state #5302

Closed
@mstanaland

Description

@mstanaland

Provide a general summary of the issue here

Using a date range picker built using the useDateRangePickerState and useDateRangePicker hooks, a keyboard user can use the DateFields to enter a date range that crosses a day marked as unavailable using the isDateUnavailable prop without triggering the invalid state.

The range is correctly considered invalid if the start or end date is unavailable, but not if the unavailable date is in the middle of the range. This is true regardless of the value of allowsNonContiguousRanges.

The behavior of selecting date using the popup calendar is correct: It does not allow the user to select a range that crosses an unavailable day.

example

🤔 Expected Behavior?

I would expect state.isInvalid to be true if the state.value range included an unavailable date.

😯 Current Behavior

state.isInvalid is false when an unavailable day falls in the middle of the state.value range.

💁 Possible Solution

No response

🔦 Context

We need to accurately show the validation state of the input.

🖥️ Steps to Reproduce

Here is a fork of the Tailwind CSS styled example modified to show the incorrect validation state:
https://codesandbox.io/s/allowsnoncontiguousranges-bug-tyckst?file=/src/App.js

Version

[email protected], [email protected]

What browsers are you seeing the problem on?

Firefox, Chrome, Safari, Microsoft Edge

If other, please specify.

No response

What operating system are you using?

MacOS 13.6

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions