Skip to content

[Bug]: WDS date picker marks the Minimum Date / Maximum Date itself as invalid #42508

Description

@Abhishek-B-R

Is there an existing issue for this?

  • I have searched the existing issues

Description

In the WDS (Anvil) date picker, picking the date that equals Minimum Date or Maximum Date shows "Please select a valid date", even though the calendar lets you pick it.

Two causes in app/client/src/widgets/wds/WDSDatePickerWidget/widget/derived.js:

  1. The bounds check is exclusive: isBetween without an inclusivity argument, and isAfter / isBefore.
  2. The validator parses min/max with new Date() (a date-only string like 2023-01-01 becomes UTC midnight) while the picker parses the same value with moment() (local midnight). Which end breaks depends on the browser time zone: in IST the minimum fails, in New York the maximum fails, in UTC both do.

#10795 and #35969 are about the older DatePickerWidget2, so this looks separate.

Steps To Reproduce

  1. Add a WDS date picker, Time Precision = Day, Minimum Date = 2023-01-01
  2. Pick 1 Jan 2023
  3. The widget shows "Please select a valid date"

Environment

Release

Severity

Low (Cosmetic or minor issue)

Proposed approach

Parse min, max and the selected date with moment() and compare inclusively at the widget's timePrecision (isBetween(..., "[]"), isSameOrAfter, isSameOrBefore), the same way DatePickerWidget2's isValidDate does. I have this with tests in derived.test.ts (passing under UTC, Asia/Kolkata and America/New_York) and would like to be assigned.

Activity

  1. linear-code commented on Oct 28, 2026

    @linear-code
  2. amiourkush commented on Oct 31, 2026

    @amiourkush

    Hi @contributor-support,

    I'd like to work on this issue.

    I've investigated the validation logic in WDSDatePickerWidget/widget/derived.js and identified two potential causes:

    1. Exclusive date-boundary comparisons.
    2. Inconsistent date parsing between JavaScript Date and Moment.js, causing timezone-dependent validation issues.

    I propose fixing these using consistent Moment.js parsing and inclusive comparisons, along with regression tests covering boundary dates and different time zones.

    Could you please assign this issue to me?

    Thanks!

  3. VCDhyan commented on Nov 10, 2026

    @VCDhyan

    Hi @Abhishek-B-R

    I would like to work on this issue.

    My understanding of the problem:

    The WDS DatePicker currently marks the Minimum Date and Maximum Date themselves as invalid, even though they are selectable in the calendar.

    This appears to be caused by two issues in derived.js:

    1. The date range validation uses exclusive comparisons (isBetween, isAfter, and isBefore), which incorrectly exclude the boundary dates.
    2. The validator uses JavaScript's new Date() to parse the minimum and maximum dates, while the date picker uses moment(). This can cause timezone inconsistencies, particularly when handling date-only values.

    My proposed solution:

    • Use moment() consistently to parse the minimum date, maximum date, and selected date.
    • Make the boundary comparisons inclusive using isBetween(..., "[]"), isSameOrAfter(), and isSameOrBefore().
    • Respect the widget's timePrecision while performing date comparisons.
    • Add or update unit tests in derived.test.ts to verify the behavior across different timezones, including UTC, Asia/Kolkata, and America/New_York.

    Before proceeding, I would appreciate your approval to work on this issue.

    Also, could you please confirm whether anyone is already working on it or if it is available to be picked up?

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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