adopted-ember-addons / adopted-ember-addons/ember-pikaday
minDate changes value when "invalid" date entered programmatically
- Lingua principale
- JavaScript
- Stelle
- 156
- Fork
- 164
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
# 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:
```hbs
```
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.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.