enter image description here

I am encountering an issue with the PrimeNG calendar component where the minimum date setting for December 2nd to 31st isn't working as expected, causing the minimum year to become disabled. If the maxdate is january 1 st to 30 then also the max year is Disabled in the year selector .

enter image description here
here the 2023 year should be Enabled.

1

There are 1 answers

0
Murugan On BEST ANSWER

This issue is still open in the github.

But we can fix this issue by CSS itself.

HTML

<p-calendar #startDate></p-calendar>

ts

 @ViewChild('startDate') datePicker;
    ngDoCheck() {
        if (this.datePicker && this.datePicker.contentViewChild) {
          let allYear = DomHandler.find(this.datePicker.contentViewChild.nativeElement, '.p-yearpicker .p-yearpicker-year');
          if (allYear.length > 0) {
            let minDate = this.datePicker._minDate != undefined ? this.datePicker._minDate.getFullYear() : undefined;
            let maxDate = this.datePicker._maxDate != undefined ? this.datePicker._maxDate.getFullYear() : undefined;
            if(minDate){
              let value = allYear.findIndex(data => data.innerText == minDate);
              if (DomHandler.hasClass(allYear[value], 'p-disabled')) {
                DomHandler.removeClass(allYear[value], 'p-disabled');
              }
            }
            if(maxDate){
              let value = allYear.findIndex(data => data.innerText == maxDate);
              if (DomHandler.hasClass(allYear[value], 'p-disabled')) {
                DomHandler.removeClass(allYear[value], 'p-disabled');
              }
            } 
          }
        }
      }