Skip to content

minDate changes value when "invalid" date entered programmatically #422

@ikirkpat

Description

@ikirkpat

Context

We have a PickadayInput that shows a start date for a goal in our application. The start date is not allowed to be modified to be in the past in relationship to when they change it. For example, if today is 10/22/2020, then the user cannot enter 10/21/2020. So we use the @minDate argument to restrict that.

So suppose the user enters 10/23/2020 as the date. All good and dandy because it's after the minDate (10/22/2020). They save it to the database. Let's say 5 days later (10/27/2020) they go to that page again. We render the component like this:

<PikadayInput
    ...
    @value={{@value}}
    @minDate={{@minDate}}
  />

The value of @minDate is the date that the component was rendered (10/27/2020) because they are now not allowed to change it to be in the past. But the value of @value is what was saved to the database to show the current value of this field: 10/23/2020. We DO want that to be shown because that's what they chose a few days earlier. It is a valid date in our eyes because at the time they chose it, it was valid. However, if they choose to change it, they should only be allowed to set it to a date in the future in relationship to when they change it (10/27/2020).

Expected

the value shown in the PickadayInput should remain whatever we tell it to be. In the case of the example above, it should be 10/23/2020. Nothing should change that unless we change it ourselves... even if the date is less than minDate. Let us control that logic. That minDate should only restrict what the user chooses in the brower... it should not change programmatic entries. Or at least we should be able to pass a flag to allow "invalid" programmatic entries because in our scenario, it's not really invalid.

Current Behavior

The value shown in the PickadayInput is reset if the value we give it is less than the minDate.

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