Skip to content

Commit

Permalink
fix(calendar range): handle unset date and selectedValue
Browse files Browse the repository at this point in the history
In the `NbCalendarRangeDayCellComponent` `date` property could be
set to `null` in case it's from bounding month and user set
`boundingMonth` to false.
In all `NbCalendarRange*CellComponent` selectedValue could be defined
but has no `start` property set. It happens because users are setting
`[range]` input on `NbCalendarRangeComponent` to `{}` so `selectedValue`
is truthy.
  • Loading branch information
yggg committed Oct 1, 2020
1 parent 9089690 commit d0850d4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class NbCalendarRangeDayCellComponent<D> extends NbBaseCalendarRangeCell<
}

if (this.selectedValue) {
return this.dateService.isSameDay(this.date, this.selectedValue.start);
return this.dateService.isSameDaySafe(this.date, this.selectedValue.start);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class NbCalendarRangeMonthCellComponent<D> extends NbBaseCalendarRangeCel
}

if (this.selectedValue) {
return this.dateService.isSameMonth(this.date, this.selectedValue.start);
return this.dateService.isSameMonthSafe(this.date, this.selectedValue.start);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class NbCalendarRangeYearCellComponent<D> extends NbBaseCalendarRangeCell
}

if (this.selectedValue) {
return this.dateService.isSameYear(this.date, this.selectedValue.start);
return this.dateService.isSameYearSafe(this.date, this.selectedValue.start);
}
}

Expand Down

0 comments on commit d0850d4

Please sign in to comment.