Skip to content

Commit 99be9cb

Browse files
authored
Merge branch 'master' into rkaraivanov/wc-chat-wrapper
2 parents bba26ce + ad2af00 commit 99be9cb

File tree

7 files changed

+63
-29
lines changed

7 files changed

+63
-29
lines changed

projects/igniteui-angular/src/lib/calendar/calendar.component.html

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -192,23 +192,25 @@ <h2 id="igx-aria-calendar-title-month" class="igx-calendar__header-date">
192192
(focus)="this.onWrapperFocus($event)"
193193
(blur)="this.onWrapperBlur($event)"
194194
>
195-
<caption id="calendar-desc" tabindex="-1" class="igx-calendar__aria-off-screen">
196-
@if (selection === 'multi') {
197-
{{ monthsViewNumber && monthsViewNumber > 1 ?
198-
resourceStrings.igx_calendar_multi_selection.replace('{0}', monthsViewNumber.toString()) :
199-
resourceStrings.igx_calendar_singular_multi_selection}}
200-
}
201-
@if (selection === 'range') {
202-
{{ monthsViewNumber && monthsViewNumber > 1 ?
203-
resourceStrings.igx_calendar_range_selection.replace('{0}', monthsViewNumber.toString()) :
204-
resourceStrings.igx_calendar_singular_range_selection}}
205-
}
206-
@if (selection === 'single') {
207-
{{ monthsViewNumber && monthsViewNumber > 1 ?
208-
resourceStrings.igx_calendar_single_selection.replace('{0}', monthsViewNumber.toString()) :
209-
resourceStrings.igx_calendar_singular_single_selection}}
195+
<div id="calendar-desc" tabindex="-1" class="igx-calendar__aria-off-screen">
196+
@switch (selection) {
197+
@case ('multi') {
198+
{{ monthsViewNumber && monthsViewNumber > 1 ?
199+
resourceStrings.igx_calendar_multi_selection.replace('{0}', monthsViewNumber.toString()) :
200+
resourceStrings.igx_calendar_singular_multi_selection}}
201+
}
202+
@case ('range') {
203+
{{ monthsViewNumber && monthsViewNumber > 1 ?
204+
resourceStrings.igx_calendar_range_selection.replace('{0}', monthsViewNumber.toString()) :
205+
resourceStrings.igx_calendar_singular_range_selection}}
206+
}
207+
@default {
208+
{{ monthsViewNumber && monthsViewNumber > 1 ?
209+
resourceStrings.igx_calendar_single_selection.replace('{0}', monthsViewNumber.toString()) :
210+
resourceStrings.igx_calendar_singular_single_selection}}
211+
}
210212
}
211-
</caption>
213+
</div>
212214
<section
213215
class="igx-calendar__pickers"
214216
[class.igx-calendar__pickers--days]="isDefaultView"

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,9 @@ export class IgxCalendarComponent extends IgxCalendarBaseDirective implements Af
439439
@HostListener('mousedown', ['$event'])
440440
protected onMouseDown(event: MouseEvent) {
441441
event.stopPropagation();
442-
this.wrapper.nativeElement.focus();
442+
if (this.platform.isBrowser && this.wrapper?.nativeElement) {
443+
this.wrapper.nativeElement.focus();
444+
}
443445
}
444446

445447
private _showActiveDay: boolean;
@@ -841,7 +843,9 @@ export class IgxCalendarComponent extends IgxCalendarBaseDirective implements Af
841843

842844
if (this.platform.isActivationKey(event)) {
843845
this.viewDate = date;
844-
this.wrapper.nativeElement.focus();
846+
if (this.platform.isBrowser && this.wrapper?.nativeElement) {
847+
this.wrapper.nativeElement.focus();
848+
}
845849
}
846850
}
847851

@@ -850,6 +854,10 @@ export class IgxCalendarComponent extends IgxCalendarBaseDirective implements Af
850854
* @internal
851855
*/
852856
public onYearsViewClick(event: MouseEvent) {
857+
if (!this.platform.isBrowser) {
858+
return;
859+
}
860+
853861
const path = event.composed ? event.composedPath() : [event.target];
854862
const years = this.dacadeView.viewItems.toArray();
855863
const validTarget = years.some(year => path.includes(year.nativeElement));
@@ -997,7 +1005,9 @@ export class IgxCalendarComponent extends IgxCalendarBaseDirective implements Af
9971005
this.activeViewIdx = activeViewIdx;
9981006
this.viewDate = date;
9991007

1000-
this.wrapper.nativeElement.focus();
1008+
if (this.platform.isBrowser && this.wrapper?.nativeElement) {
1009+
this.wrapper.nativeElement.focus();
1010+
}
10011011
}
10021012
}
10031013

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
import { Injectable, ElementRef, NgZone } from "@angular/core";
1+
import { Injectable, ElementRef, NgZone, inject } from "@angular/core";
22
import { EventManager } from "@angular/platform-browser";
3+
import { PlatformUtil } from "../core/utils";
34

45
@Injectable()
56
export class KeyboardNavigationService {
67
private keyHandlers = new Map<string, (event: KeyboardEvent) => void>();
78
private eventUnsubscribeFn: Function | null = null;
9+
private platform = inject(PlatformUtil);
810

911
constructor(
1012
private eventManager: EventManager,
1113
private ngZone: NgZone,
1214
) {}
1315

1416
public attachKeyboardHandlers(elementRef: ElementRef, context: any) {
17+
if (!this.platform.isBrowser) {
18+
return this;
19+
}
20+
1521
this.detachKeyboardHandlers(); // Clean up any existing listeners
1622

1723
this.ngZone.runOutsideAngular(() => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective {
349349
});
350350
}
351351

352-
if (this.tabIndex !== -1) {
352+
if (this.tabIndex !== -1 && this.platform.isBrowser && this.el?.nativeElement) {
353353
this.el.nativeElement.focus();
354354
}
355355

projects/igniteui-angular/src/lib/calendar/month-picker/month-picker.component.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ export class IgxMonthPickerComponent extends IgxCalendarBaseDirective implements
152152

153153
if (this.platform.isActivationKey(event)) {
154154
this.viewDate = date;
155-
this.wrapper.nativeElement.focus();
155+
if (this.platform.isBrowser && this.wrapper?.nativeElement) {
156+
this.wrapper.nativeElement.focus();
157+
}
156158
}
157159
}
158160

@@ -188,9 +190,13 @@ export class IgxMonthPickerComponent extends IgxCalendarBaseDirective implements
188190
public override activeViewDecade() {
189191
super.activeViewDecade();
190192

191-
requestAnimationFrame(() => {
192-
this.dacadeView.el.nativeElement.focus();
193-
});
193+
if (this.platform.isBrowser) {
194+
requestAnimationFrame(() => {
195+
if (this.dacadeView?.el?.nativeElement) {
196+
this.dacadeView.el.nativeElement.focus();
197+
}
198+
});
199+
}
194200
}
195201

196202
/**
@@ -221,7 +227,9 @@ export class IgxMonthPickerComponent extends IgxCalendarBaseDirective implements
221227
);
222228

223229
this.activeView = IgxCalendarView.Year;
224-
this.wrapper.nativeElement.focus();
230+
if (this.platform.isBrowser && this.wrapper?.nativeElement) {
231+
this.wrapper.nativeElement.focus();
232+
}
225233
}
226234

227235
/**
@@ -279,7 +287,9 @@ export class IgxMonthPickerComponent extends IgxCalendarBaseDirective implements
279287
@HostListener('mousedown', ['$event'])
280288
protected onMouseDown(event: MouseEvent) {
281289
event.stopPropagation();
282-
this.wrapper.nativeElement.focus();
290+
if (this.platform.isBrowser && this.wrapper?.nativeElement) {
291+
this.wrapper.nativeElement.focus();
292+
}
283293
}
284294

285295
private _showActiveDay: boolean;

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
ElementRef,
66
booleanAttribute,
77
Inject,
8+
inject,
89
} from "@angular/core";
910
import { IgxCalendarMonthDirective } from "../calendar.directives";
1011
import { TitleCasePipe } from "@angular/common";
@@ -16,6 +17,7 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms";
1617
import { CalendarDay } from "../common/model";
1718
import type { DayInterval } from "../common/model";
1819
import { calendarRange } from "../common/helpers";
20+
import { PlatformUtil } from "../../core/utils";
1921

2022
let NEXT_ID = 0;
2123

@@ -37,6 +39,7 @@ let NEXT_ID = 0;
3739
})
3840
export class IgxMonthsViewComponent extends IgxCalendarViewDirective implements ControlValueAccessor {
3941
#standalone = true;
42+
private platform = inject(PlatformUtil);
4043

4144
/**
4245
* Sets/gets the `id` of the months view.
@@ -139,7 +142,7 @@ export class IgxMonthsViewComponent extends IgxCalendarViewDirective implements
139142
* @hidden
140143
*/
141144
protected onMouseDown() {
142-
if (this.tabIndex !== -1) {
145+
if (this.tabIndex !== -1 && this.platform.isBrowser && this.el?.nativeElement) {
143146
this.el.nativeElement.focus();
144147
}
145148
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
HostBinding,
55
ElementRef,
66
Inject,
7+
inject,
78
} from "@angular/core";
89
import { IgxCalendarYearDirective } from "../calendar.directives";
910
import {
@@ -14,6 +15,7 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms";
1415
import { CalendarDay } from "../common/model";
1516
import type { DayInterval } from "../common/model";
1617
import { calendarRange } from "../common/helpers";
18+
import { PlatformUtil } from "../../core/utils";
1719

1820
@Component({
1921
providers: [
@@ -33,6 +35,7 @@ import { calendarRange } from "../common/helpers";
3335
})
3436
export class IgxYearsViewComponent extends IgxCalendarViewDirective implements ControlValueAccessor {
3537
#standalone = true;
38+
private platform = inject(PlatformUtil);
3639

3740
/**
3841
* The default css class applied to the component.
@@ -158,7 +161,7 @@ export class IgxYearsViewComponent extends IgxCalendarViewDirective implements C
158161
* @hidden
159162
*/
160163
protected onMouseDown() {
161-
if (this.tabIndex !== -1) {
164+
if (this.tabIndex !== -1 && this.platform.isBrowser && this.el?.nativeElement) {
162165
this.el.nativeElement.focus();
163166
}
164167
}

0 commit comments

Comments
 (0)