Skip to content

Commit

Permalink
fix(calendar): treat value type accordingly #4282
Browse files Browse the repository at this point in the history
  • Loading branch information
hanastasov committed Sep 13, 2019
1 parent 978dd57 commit b883778
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,23 @@ export class IgxDaysViewComponent extends IgxCalendarBase implements DoCheck {
* @hidden
*/
public isSelected(date: ICalendarDate): boolean {
const selectedDates = (this.value as Date[]);
let selectedDates: Date | Date[];
if (!date.isCurrentMonth) {
return false;
}

if (!this.value || selectedDates.length === 0) {
if (!this.value || (Array.isArray(this.value) && this.value.length === 0)) {
return false;
}

if (selectedDates.length === 1) {
return this.value[0].getTime() === date.date.getTime();
if (this.selection === CalendarSelection.SINGLE) {
selectedDates = (this.value as Date);
return this.getDateOnly(selectedDates).getTime() === date.date.getTime();
}

selectedDates = (this.value as Date[]);
if (this.selection === CalendarSelection.RANGE && selectedDates.length === 1) {
return this.getDateOnly(selectedDates[0]).getTime() === date.date.getTime();
}

if (this.selection === CalendarSelection.MULTI) {
Expand Down

0 comments on commit b883778

Please sign in to comment.