Skip to content

Commit

Permalink
fix(core/datepicker): date picker months and years (#145)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Leroux <daniel.leroux@siemens.com>
  • Loading branch information
goncalosard and danielleroux committed Nov 17, 2022
1 parent 8088522 commit e42cae2
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions packages/core/src/components/date-picker/date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,6 @@ export class DatePicker {
}
}

private selectionProps() {
if (this.year !== null) {
this.yearValue = this.year;
}

if (this.month !== null) {
this.monthValue = this.month;
}
}

private getStartOfMonth(
year = DateTime.local().get('year'),
month = DateTime.local().get('month')
Expand All @@ -227,7 +217,6 @@ export class DatePicker {
}

private calculateCalendar() {
this.selectionProps();
const start = this.getStartOfMonth(this.yearValue, this.monthValue);
const end = this.getEndOfMonth(this.yearValue, this.monthValue);
const totalDays = this.getDaysInMonth(start, end);
Expand Down Expand Up @@ -286,7 +275,6 @@ export class DatePicker {
} else {
this.monthValue += number;
}

this.calculateCalendar();
}

Expand Down Expand Up @@ -423,6 +411,15 @@ export class DatePicker {
);
}

componentWillLoad() {
if (this.year !== null) {
this.yearValue = this.year;
}
if (this.month) {
this.monthValue = this.month;
}
}

componentWillRender() {
this.calculateCalendar();
}
Expand Down

0 comments on commit e42cae2

Please sign in to comment.