-
Notifications
You must be signed in to change notification settings - Fork 6.7k
DatePicker - manually editing date to an invalid date then back to valid date not working. #3736
Comments
I believe this is also causing a more common type of error. If you completely clear the date and then type 2014-05-05 |
At the moment Datepicker as quite a lot open issues. We're currently planning a large refactor on that particular module of UI Bootstrap but don't hold your breath. |
I would suggest that the datepicker is marked deprecated in the documentation so people don't start using it in production environments. |
It's not deprecated, it's just not actively developed at the moment. |
Perhaps deprecated was the wrong word. A notice exactly like your comment would probably help set the right expectations so people don't feel burnt.
|
Good one. I'll discuss it with the other maintainers right away. |
Glad I found this thread, I've had tons of headaches getting the validation working properly. |
I have a solution for this one. I had a format of yyyy/MM/dd. Doing any edit that made this momentarily invalid would create an invalid date object. The date picker would use this invalid date that it assigned to the model (variable named 'baseDate') as the starting point for creating a new date. Except many of the fields are NaN. By checking for this condition before using the date as a baseline, the problem is avoided. I just added a isNaN(baseDate) at the appropriate place. Here is the git diff. diff --git a/ui-bootstrap-tpls-0.13.0.js b/ui-bootstrap-tpls-0.13.0.js index 6119661..dac366f 100644 --- a/ui-bootstrap-tpls-0.13.0.js +++ b/ui-bootstrap-tpls-0.13.0.js @@ -781,7 +781,7 @@ angular.module('ui.bootstrap.dateparser', []) if ( results && results.length ) { var fields, dt; - if (baseDate) { + if (baseDate && !isNaN(baseDate) ) { fields = { year: baseDate.getFullYear(), month: baseDate.getMonth(), |
+1 |
+1 Nice work @davidcox66, any chance of raising a pull request? |
👍 |
|
Steps to reproduce:
Scenario 1:
http://plnkr.co/edit/vDeypZk4Gq7odCTGRIMf?p=preview
Expected/Actual: This is an invalid date, the "Value" underneath goes blank
Expected: This is now a valid date again, the "Value" underneath should be displayed
Actual: The value stays blank
Scenario 2:
http://plnkr.co/edit/vDeypZk4Gq7odCTGRIMf?p=preview
Expected/Actual: This is an invalid date, the "Value" underneath goes blank
Expected: This is now a valid date again, the "Value" underneath should be displayed
Actual: It stays blank
I see these results in both Chrome and Firefox latest.
In Chrome Only: In scenario 2 if you type 3 instead of 03, everything works as expected.
The text was updated successfully, but these errors were encountered: