Skip to content

Commit b883778

Browse files
committed
fix(calendar): treat value type accordingly #4282
1 parent 978dd57 commit b883778

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

projects/igniteui-angular/src/lib/calendar/days-view/days-view.component.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,23 @@ export class IgxDaysViewComponent extends IgxCalendarBase implements DoCheck {
207207
* @hidden
208208
*/
209209
public isSelected(date: ICalendarDate): boolean {
210-
const selectedDates = (this.value as Date[]);
210+
let selectedDates: Date | Date[];
211211
if (!date.isCurrentMonth) {
212212
return false;
213213
}
214214

215-
if (!this.value || selectedDates.length === 0) {
215+
if (!this.value || (Array.isArray(this.value) && this.value.length === 0)) {
216216
return false;
217217
}
218218

219-
if (selectedDates.length === 1) {
220-
return this.value[0].getTime() === date.date.getTime();
219+
if (this.selection === CalendarSelection.SINGLE) {
220+
selectedDates = (this.value as Date);
221+
return this.getDateOnly(selectedDates).getTime() === date.date.getTime();
222+
}
223+
224+
selectedDates = (this.value as Date[]);
225+
if (this.selection === CalendarSelection.RANGE && selectedDates.length === 1) {
226+
return this.getDateOnly(selectedDates[0]).getTime() === date.date.getTime();
221227
}
222228

223229
if (this.selection === CalendarSelection.MULTI) {

0 commit comments

Comments
 (0)