aavanzyl / ngx-tiny

Implementation of Light Weight Angular Components for Production Applications
https://aavanzyl.github.io/ngx-tiny
MIT License
7 stars 3 forks source link

Date Picker: No initial value shown, even if set. #13

Open clintonmyers opened 4 years ago

clintonmyers commented 4 years ago

Hello, I'm not sure if this is a bug or feature request, but I noticed (after jumping into development), that the examples in the docs do not display the initial date value inside the tag that was set in the TypeScript (looking at the single date example for instance). I am doing reactive forms where initial or asynchronous values will need to be set programmatically and displayed, and not all values will be set with the datepicker itself. Is this intentionally set up this way with this functionality unwanted, or perhaps I've made a mistake and this functionality is currently possible (user error). I am able to use the date picker successfully with my form otherwise for dates that I set manually. Thanks!

https://aavanzyl.github.io/ngx-tiny/project/date-picker Usage tab

aavanzyl commented 4 years ago

@clintonmyers This looks like a bug, I will need to correct this and revert back to you, wont take too long :)

The expected behavior is when setting/changing a date, the display is update. It is updating when setting a new date from the UI, but not from the controller. Will sort this out for you asap

clintonmyers commented 4 years ago

Thanks so much for the quick response!

aavanzyl commented 4 years ago

@clintonmyers I have made the fix and published v10.0.1, please test and let me know if its working on your side as well.

clintonmyers commented 4 years ago

The dates are now coming in, but the date picker isn't picking up my DatePickerOptions for my displayFormat on the initial load, only when I set a date manually. Initially it will display Jan 1, 2020 from my API data, then once I use the date picker and select another date it will display 1/1/2020, my intended format. Thanks again @aavanzyl.

clintonmyers commented 4 years ago

@aavanzyl, I was wondering, did you have a chance to look into this yet? Thanks, again. Clint

aavanzyl commented 4 years ago

@clintonmyers I have deployed version 10.2 to fix the issue you are referring to. Please test and let me know.

clintonmyers commented 4 years ago

Thank you for the help @aavanzyl . Another developer on my team was able to use a short setTimeout to bypass the issue. I will remove the setTimeout and report back.

clintonmyers commented 4 years ago

@aavanzyl The other developer told me that the update did not solve the problem when he removed the setTimeout. I'm going to continue to use the setTimeout for now. Thanks.

mishelka commented 3 years ago

I have the same issue, but the value does not display at all when changing externally. I'm using the same example as the last one in the demo, initial value is always set to today and when I'm using two inline calendars with the same value, the other one does not update the view despite the source value is being updated.

<div class="pb-2 text-textcolor">Select a date</div>
<div class="w-full relative" style="height: 300px">
    <ngx-date-picker [(value)]="singleDate" [options]="datePickerOptions"
                     class="inline responsive"
    ></ngx-date-picker>
</div>

<div class="w-full relative" style="height: 300px">
  <ngx-date-picker [(value)]="singleDate" [options]="datePickerOptions"
                   class="inline"
  ></ngx-date-picker>
</div>

{{singleDate}}

Try selecting date on any of the calendars. Expected behavior: The is-selected class should be updated according to current value and the view should switch to current year and month on component init and after each value update.

Browser: Chrome Angular version: 11.1.0 Date picker version: 10.0.2