Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ikirkpat opened this issue Oct 22, 2020 · 1 comment
Open

Comments

@ikirkpat
Copy link

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.

@ikirkpat
Copy link
Author

ikirkpat commented Mar 11, 2021

Just wondering if anyone has looked at this yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant