ng2-ui / datetime-picker

Angular2 DateTime Picker
https://ng2-ui.github.io/#/datetime-picker
MIT License
121 stars 62 forks source link

Remove "change" host listener #46

Closed 0cv closed 7 years ago

0cv commented 7 years ago

This shall resolve https://github.com/ng2-ui/ng2-datetime-picker/issues/44 Additionally add the Tab and Enter key code to close the Datepicker

@allenhwkim I have a doubt what the change listener was used for. By removing it, it resolves the mentioned issue but I couldn't identify any side effect. Have you any idea, or concern?

allenhwkim commented 7 years ago

@Krisa Thanks for this changes.

(change) was used to detect the value when user manually change the value. Without ngModel and ngModelChange, I think the value manually changed will not open a proper date. However, let's see how it goes.

Currently we don't have a solid tests, and I am building a test framework for all our UI web browser tests.

0cv commented 7 years ago

I see. But on another hand, we only have ngModel and formControl. And both are working fine (or seem to) without the change listener. But maybe it's because there was before a custom way to subscribe to changes?

Anyway test framework will definitely be useful.

allenhwkim commented 7 years ago

yes user can selectngModel or formControl to detect changes for now. I think it's good enough.

odisi commented 7 years ago

I get the code with changes but it doesn't work. I do changes and work to me. The changes following: In ngOnChanges method i iserted: if (this.dateFormat.length == (newNgModel != null ? newNgModel.length : -1)) { this.hideDatetimePicker(); this.showDatetimePicker(); }

In valueChanged method I comment: //else if (typeof date === 'undefined') { // this.el['dateValue'] = null; // }

I don't know if this changes break anything. I tested and work.

Anybody can help me?

0cv commented 7 years ago

@odisi can you create a plunkr (and open a separated issue unless this is related to this PR)?

Also, please note that following code is all what you need to get to work the datepicker:

    <form [formGroup]="myForm">
        <input formControlName="date"  ng2-datetime-picker close-on-select="false"/>
    </form>
odisi commented 7 years ago

If the user type a date like 2010-08-01, the calendar don't select the typed date.

0cv commented 7 years ago

if you try the plunkr https://plnkr.co/edit/su2aiL?p=preview, it does.

odisi commented 7 years ago

I tested and don't work. My test was: Type a date like 1984-01-08 and the calendar select and show the typed date.

0cv commented 7 years ago

Working well in Chrome... image

Of course you need to close the datepicker and reopen it, i.e. there is not a "real-time" binding

odisi commented 7 years ago

Yes, It's this that I'm talking about. To work in "real-time" like a jquery ui or others. I do a change that close and open the calendar to work like "real-time".

0cv commented 7 years ago

Makes sense. Let's track that somewhere else