Aurelia-Bootstrap-Plugins icon indicating copy to clipboard operation
Aurelia-Bootstrap-Plugins copied to clipboard

Time-only picker loses date portion of original value

Open jordan-ware opened this issue 5 years ago • 8 comments

I'd label this is more of an enhancement, but:

If you bind two controls to the same date, e.g. one control with a date format of DD/MM/YYYY and one with a time format of hh:mm a, the second control will end up losing the date portion of the original value as it reads it's own strings from the input value and then syncs with the model property.

I think the optimal solution here is to have an extra internal property that actually binds with the bootstrap datetimepicker input, e.g. internalValue which will then publish any input changes to the bindable model and value properties that are exposed. Using this method we can ensure that the date portion is not lost during the sync process.

The same method of identifying if it's only a time value can be taken from the underlying datepicker library (see their hasDate, hasTime and isEnabled functions). This can be used to check for this scenario and ensure that the date portion is not lost.

An example of the issue below in the log statements, you can see as valueChanged triggers an update on model, it loses the date portion and resets to the current date (12th of February in this case).

I'm starting to get an understanding of this wrapper, I might be able to get a PR around this.

image

jordan-ware avatar Feb 12 '19 04:02 jordan-ware