Skip to content

Commit

Permalink
Fixed #11024 - Calendar | Displayed year doesn't update for month picker
Browse files Browse the repository at this point in the history
  • Loading branch information
yigitfindikli committed Jan 4, 2022
1 parent 08a54d7 commit 7493589
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/app/components/calendar/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface LocaleSettings {
{{getMonthName(month.month)}}
</button>
<button type="button" (click)="switchToYearView($event)" (keydown)="onContainerButtonKeydown($event)" *ngIf="currentView !== 'year'" class="p-datepicker-year p-link" [disabled]="switchViewButtonDisabled()">
{{month.year}}
{{getYear(month)}}
</button>
<span class="p-datepicker-decade" *ngIf="currentView === 'year'">
<ng-container *ngIf="!decadeTemplate">{{yearPickerValues()[0]}} - {{yearPickerValues()[yearPickerValues().length - 1]}}</ng-container>
Expand Down Expand Up @@ -1396,6 +1396,9 @@ export class Calendar implements OnInit,OnDestroy,ControlValueAccessor {
return this.config.getTranslation('monthNames')[index];
}

getYear(month) {
return this.currentView === 'month' ? this.currentYear : month.year;
}

switchViewButtonDisabled() {
return this.numberOfMonths > 1 || this.disabled;
Expand Down

0 comments on commit 7493589

Please sign in to comment.