-
Notifications
You must be signed in to change notification settings - Fork 724
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
Date field cannot be typed in #1305
Comments
Please fix this. (T_T) |
I patched my DateField to be able to work with the date selector fixing the timezone diff:
|
@matheo, if your patch fix both issues, can you create a PR for it please ? |
Done ;) #1317 |
Yup, the infinite loop is now fixed with my PR #1318. It will be published soon! |
I misunderstood the issue, it's about manually edit the date field. I re-open the issue, sorry for the inconvenience ! |
If you have a 'date' field, you can no longer type the date in it explicitly. Attempting to modify an existing date also just deletes it.
You can see the behaviour in the ng-admin demo - https://marmelab.com/ng-admin-demo/index.html#/customers/edit/485 - try changing the birthday without opening the picker.
I think this was broken by #899 - it used to work in an older version of ng-admin.
The problem is because maDateField watches both value and rawValue:
The problem is, if at any point an invalid date string is in the box - suppose the string 'foo'. The following sequence happens:
$watch('rawValue'
seesfoo
. This is not a date object, soparse
leaves it unchanged, andvalue
is set tofoo
.$watch('value'
seesfoo
and attempts to construct a new Date object using it. This ends up settingrawValue
to anInvalid Date
object.$watch('rawValue'
seesInvalid Date
. This is a date object, soparse
tries to manipulate it, but fails and ends up setting the value tonull
.$watch('value'
seesnull
and correspondingly setsrawValue
tonull
$watch('rawValue'
seesnull
and correspondingly setsvalue
tonull
$watch('value'
seesnull
, this is the same as the last value, and the cycle ends!The net result is
null
- which removes the text you tried to write from the box.This is related to #1271 which will be caused by a similar loop. However in that case, if you are in a timezone, the value/rawValue watches will loop, and because the 'parse' method applies a timezone correction the value never stabilises (resulting in the infinite loop).
The text was updated successfully, but these errors were encountered: