h2qutc / angular-material-components

Angular Material Library provide extra components for every project
https://h2qutc.github.io/angular-material-components/
MIT License
320 stars 148 forks source link

No Default Start Date #356

Open shivamkatyan opened 8 months ago

shivamkatyan commented 8 months ago

I recently migrated to v16.x from v9.x during my migration to angular v16.2.x IN previous version if there was no default value, then datetime picker would default to current date and time, but now it is just blank.

I have tried seeting up a startDate and defaultTime but they do not work as well.

if there is value in form then it works correctly,

image

if there is no date time set then

image

stackblitz: https://stackblitz.com/github/shivamkatyan/angular-material-components

shivamkatyan commented 8 months ago

For now i have a dirty fix to resolve the issue on my side. I am using opened event of datetime picker and manually setting the date if no value exists in formcontrol's value.

` <ngx-mat-datetime-picker

picker

      [showSpinners]="showSpinners"
      [showSeconds]="showSeconds"
      [stepHour]="stepHour"
      [stepMinute]="stepMinute"
      [stepSecond]="stepSecond"
      [touchUi]="touchUi"
      [color]="color"
      [enableMeridian]="enableMeridian"
      [disableMinute]="disableMinute"
      [hideTime]="hideTime",
      (opened)="setOpenedDate(picker)"
    >`

and public setOpenedDate(datePicker: any): void { const dateCtrl: FormControl = this.dateControl; dateCtrl.setValue(dateCtrl.value || new Date()); datePicker._selected = dateCtrl.value; datePicker.startAt = datePicker._selected; }

This is just a dirty workaround, if anyone have a better workaround or a fix, please update

arjen-t commented 6 months ago

I can confirm the defaultTime property seems to be broken, I think it has something to do with commit #1d7387a https://github.com/h2qutc/angular-material-components/commit/1d7387ac2b9ab0fb345ef270d6cca5d25d07536a

@h2qutc could you please look in to this/give feedback?

deepthy-dev commented 2 months ago

@h2qutc Any update on this issue?

lilas78 commented 2 months ago

@h2qutc Could we have a fix for this issue ?

lilas78 commented 2 months ago

For now i have a dirty fix to resolve the issue on my side. I am usign opened event of datetime picker and manually setting the date if no value exists in formcontrol's value.

<ngx-mat-datetime-picker #picker [showSpinners]="showSpinners" [showSeconds]="showSeconds" [stepHour]="stepHour" [stepMinute]="stepMinute" [stepSecond]="stepSecond" [touchUi]="touchUi" [color]="color" [enableMeridian]="enableMeridian" [disableMinute]="disableMinute" [hideTime]="hideTime", (opened)="setOpenedDate(picker)" >

and public setOpenedDate(datePicker: any): void { const dateCtrl: FormControl = this.dateControl; dateCtrl.setValue(dateCtrl.value || new Date()); datePicker._selected = dateCtrl.value; datePicker.startAt = datePicker._selected; }

This is just a dirty workaround, if anyone have a better workaround or a fix, please update

@shivamkatyan I tried your workaround. But there is still no selected date and hour in the UI (startAt is correctly set in the model). Is there any other modifications you made to apply the start date to the view ?

samuele-ruffino96 commented 2 months ago

For now i have a dirty fix to resolve the issue on my side. I am usign opened event of datetime picker and manually setting the date if no value exists in formcontrol's value. <ngx-mat-datetime-picker #picker [showSpinners]="showSpinners" [showSeconds]="showSeconds" [stepHour]="stepHour" [stepMinute]="stepMinute" [stepSecond]="stepSecond" [touchUi]="touchUi" [color]="color" [enableMeridian]="enableMeridian" [disableMinute]="disableMinute" [hideTime]="hideTime", (opened)="setOpenedDate(picker)" > and public setOpenedDate(datePicker: any): void { const dateCtrl: FormControl = this.dateControl; dateCtrl.setValue(dateCtrl.value || new Date()); datePicker._selected = dateCtrl.value; datePicker.startAt = datePicker._selected; } This is just a dirty workaround, if anyone have a better workaround or a fix, please update

@shivamkatyan I tried your workaround. But there is still no selected date and hour in the UI (startAt is correctly set in the model). Is there any other modifications you made to apply the start date to the view ?

I've opened a MR to solve this. Hope it'll be merged soon 😄

NityaSantosh26 commented 3 weeks ago

@samuele-ruffino96 Is your fix working? Does that solve the issue of not showing empty time fields in the UI? Because I see the MR you've created is closed without merging.

samuele-ruffino96 commented 3 weeks ago

@samuele-ruffino96 Is your fix working? Does that solve the issue of not showing empty time fields in the UI? Because I see the MR you've created is closed without merging.

Yes, it does. I closed it because this repo was probably no longer be maintained by @h2qutc. A reworking is currently in progress (link below). If it's gonna succeed, i'll reopen a PR there if the issue still persist.

https://github.com/SeraphCoding/angular-material-components

RaghniP commented 1 week ago

@samuele-ruffino96 Any update on your PR in the new reworked repository (link you provided in your previous message)? There seems to be no ETA for completion of reworking. The workaround proposed before isn't working for me.

RaghniP commented 1 week ago

For now i have a dirty fix to resolve the issue on my side. I am usign opened event of datetime picker and manually setting the date if no value exists in formcontrol's value. <ngx-mat-datetime-picker #picker [showSpinners]="showSpinners" [showSeconds]="showSeconds" [stepHour]="stepHour" [stepMinute]="stepMinute" [stepSecond]="stepSecond" [touchUi]="touchUi" [color]="color" [enableMeridian]="enableMeridian" [disableMinute]="disableMinute" [hideTime]="hideTime", (opened)="setOpenedDate(picker)" > and public setOpenedDate(datePicker: any): void { const dateCtrl: FormControl = this.dateControl; dateCtrl.setValue(dateCtrl.value || new Date()); datePicker._selected = dateCtrl.value; datePicker.startAt = datePicker._selected; } This is just a dirty workaround, if anyone have a better workaround or a fix, please update

@shivamkatyan I tried your workaround. But there is still no selected date and hour in the UI (startAt is correctly set in the model). Is there any other modifications you made to apply the start date to the view ?

@lilas78 I'm facing the same issue. Have you found a solution to resolve it?