Skip to content

Commit 54613fd

Browse files
authored
Merge branch '10.2.x' into ddimitrov/fix-8425-10.2.x
2 parents 53cfa38 + 43a1c8b commit 54613fd

File tree

3 files changed

+62
-6
lines changed

3 files changed

+62
-6
lines changed

projects/igniteui-angular/src/lib/calendar/calendar-base.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,16 @@ export class IgxCalendarBaseDirective implements ControlValueAccessor {
156156
*/
157157
public set value(value: Date | Date[]) {
158158
if (!value || !!value && (value as Date[]).length === 0) {
159+
this.selectedDatesWithoutFocus = new Date();
159160
return;
160161
}
161-
162+
if (!this.selectedDatesWithoutFocus) {
163+
const valueDate = value[0] ? Math.min.apply(null, value) : value;
164+
const date = this.getDateOnly(new Date(valueDate)).setDate(1);
165+
this.viewDate = new Date(date);
166+
}
162167
this.selectDate(value);
168+
this.selectedDatesWithoutFocus = value;
163169
}
164170

165171
/**
@@ -175,6 +181,9 @@ export class IgxCalendarBaseDirective implements ControlValueAccessor {
175181
* Sets the date that will be presented in the default view when the component renders.
176182
*/
177183
public set viewDate(value: Date) {
184+
if (this._viewDate) {
185+
this.selectedDatesWithoutFocus = value;
186+
}
178187
const date = this.getDateOnly(value).setDate(1);
179188
this._viewDate = new Date(date);
180189
}
@@ -380,6 +389,11 @@ export class IgxCalendarBaseDirective implements ControlValueAccessor {
380389
*/
381390
public selectedDates;
382391

392+
/**
393+
* @hidden
394+
*/
395+
private selectedDatesWithoutFocus;
396+
383397
/**
384398
* @hidden
385399
*/

projects/igniteui-angular/src/lib/calendar/calendar.component.spec.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ describe('IgxCalendar - ', () => {
174174
configureTestSuite();
175175
beforeAll(async(() => {
176176
TestBed.configureTestingModule({
177-
declarations: [IgxCalendarSampleComponent, IgxCalendarRangeComponent, IgxCalendarDisabledSpecialDatesComponent],
177+
declarations: [IgxCalendarSampleComponent, IgxCalendarRangeComponent, IgxCalendarDisabledSpecialDatesComponent,
178+
IgxCalendarValueComponent],
178179
imports: [IgxCalendarModule, FormsModule, NoopAnimationsModule]
179180
}).compileComponents();
180181
}));
@@ -291,6 +292,27 @@ describe('IgxCalendar - ', () => {
291292
expect(bodyMonth.nativeElement.textContent.trim()).toMatch('8');
292293
});
293294

295+
it('Should show right month when value is set', () => {
296+
fixture = TestBed.createComponent(IgxCalendarValueComponent);
297+
fixture.detectChanges();
298+
calendar = fixture.componentInstance.calendar;
299+
300+
expect(calendar.weekStart).toEqual(WEEKDAYS.SUNDAY);
301+
expect(calendar.selection).toEqual('single');
302+
expect(calendar.viewDate.getMonth()).toEqual(calendar.value.getMonth());
303+
304+
const date = new Date(2020, 8, 28);
305+
calendar.viewDate = date;
306+
fixture.detectChanges();
307+
308+
expect(calendar.viewDate.getMonth()).toEqual(date.getMonth());
309+
310+
calendar.value = new Date(2020, 9, 15);
311+
fixture.detectChanges();
312+
313+
expect(calendar.viewDate.getMonth()).toEqual(date.getMonth());
314+
});
315+
294316
it('Should properly set locale', () => {
295317
fixture.componentInstance.viewDate = new Date(2018, 8, 17);
296318
fixture.componentInstance.model = new Date();
@@ -1998,6 +2020,16 @@ export class IgxCalendarDisabledSpecialDatesComponent {
19982020
@ViewChild(IgxCalendarComponent, { static: true }) public calendar: IgxCalendarComponent;
19992021
}
20002022

2023+
@Component({
2024+
template: `
2025+
<igx-calendar [value]="value"></igx-calendar>
2026+
`
2027+
})
2028+
export class IgxCalendarValueComponent {
2029+
public value = new Date(2020, 7, 13);
2030+
@ViewChild(IgxCalendarComponent, { static: true }) public calendar: IgxCalendarComponent;
2031+
}
2032+
20012033
class DateTester {
20022034
// tests whether a date is disabled or not
20032035
static testDatesAvailability(dates: IgxDayItemComponent[], disabled: boolean) {

projects/igniteui-angular/src/lib/core/styles/themes/schemas/dark/_action-strip.scss

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,24 @@ $_dark-action-strip: extend(
2828
/// Generates a dark fluent action strip schema.
2929
/// @type {Map}
3030
/// @requires {function} extend
31-
/// @requires $_fluent-action-strip
32-
$_dark-fluent-action-strip: extend($_fluent-action-strip);
31+
/// @requires $_dark-action-strip
32+
$_dark-fluent-action-strip: extend(
33+
$_dark-action-strip,
34+
(
35+
variant: 'fluent'
36+
)
37+
);
3338

3439
/// Generates a dark bootstrap action strip schema.
3540
/// @type {Map}
3641
/// @requires {function} extend
37-
/// @requires $_bootstrap-action-strip
38-
$_dark-bootstrap-action-strip: extend($_bootstrap-action-strip);
42+
/// @requires $_dark-action-strip
43+
$_dark-bootstrap-action-strip: extend(
44+
$_dark-action-strip,
45+
(
46+
variant: 'bootstrap'
47+
)
48+
);
3949

4050
/// Generates a dark indigo action strip schema.
4151
/// @type {Map}

0 commit comments

Comments
 (0)