Skip to content

Commit 1787e9d

Browse files
authored
Merge branch '20.1.x' into sivanova/combo-theming-20.1.x
2 parents 498cd17 + 2fa91b3 commit 1787e9d

File tree

10 files changed

+87
-51
lines changed

10 files changed

+87
-51
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
}

projects/igniteui-angular/src/lib/directives/button/button-base.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
Output,
99
booleanAttribute,
1010
inject,
11-
afterRenderEffect,
11+
AfterViewInit,
1212
} from '@angular/core';
1313
import { PlatformUtil } from '../../core/utils';
1414

@@ -20,8 +20,9 @@ export const IgxBaseButtonType = {
2020

2121

2222
@Directive()
23-
export abstract class IgxButtonBaseDirective {
23+
export abstract class IgxButtonBaseDirective implements AfterViewInit{
2424
private _platformUtil = inject(PlatformUtil);
25+
private _viewInit = false;
2526

2627
/**
2728
* Emitted when the button is clicked.
@@ -101,15 +102,16 @@ export abstract class IgxButtonBaseDirective {
101102
// In SSR there is no paint, so there’s no visual rendering or transitions to suppress.
102103
// Fix style flickering https://github.com/IgniteUI/igniteui-angular/issues/14759
103104
if (this._platformUtil.isBrowser) {
104-
afterRenderEffect({
105-
write: () => {
106-
this.element.nativeElement.style.setProperty('--_init-transition', '0s');
107-
},
108-
read: () => {
109-
requestAnimationFrame(() => {
110-
this.element.nativeElement.style.removeProperty('--_init-transition');
111-
});
112-
}
105+
this.element.nativeElement.style.setProperty('--_init-transition', '0s');
106+
}
107+
}
108+
109+
public ngAfterViewInit(): void {
110+
if (this._platformUtil.isBrowser && !this._viewInit) {
111+
this._viewInit = true;
112+
113+
requestAnimationFrame(() => {
114+
this.element.nativeElement.style.removeProperty('--_init-transition');
113115
});
114116
}
115117
}

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4106,7 +4106,10 @@ export abstract class IgxGridBaseDirective implements GridType,
41064106
return this._activeRowIndexes;
41074107
} else {
41084108
const activeRow = this.navigation.activeNode?.row;
4109-
const selectedCellIndexes = (this.selectionService.selection?.keys() as any)?.toArray();
4109+
4110+
const selectedCellIndexes = this.selectionService.selection
4111+
? Array.from(this.selectionService.selection.keys())
4112+
: [];
41104113
this._activeRowIndexes = [activeRow, ...selectedCellIndexes];
41114114
return this._activeRowIndexes;
41124115
}

projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6580,27 +6580,24 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
65806580

65816581
// Scroll the search list to the bottom.
65826582
let scrollbar = GridFunctions.getExcelStyleSearchComponentScrollbar(fix);
6583+
expect(scrollbar.scrollTop).toBe(0);
6584+
let listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix);
6585+
expect(listItems[0].innerText).toBe('Select All');
6586+
65836587
scrollbar.scrollTop = 3000;
65846588
await wait();
65856589
fix.detectChanges();
6590+
expect(listItems[0].innerText).not.toBe('Select All');
6591+
expect(scrollbar.scrollTop).toBeGreaterThan(300);
65866592

65876593
// Select another column
65886594
GridFunctions.clickExcelFilterIcon(fix, 'Downloads');
65896595
await wait();
65906596
fix.detectChanges();
65916597

65926598
// Update scrollbar
6593-
const searchComponent = GridFunctions.getExcelStyleSearchComponent(fix);
65946599
scrollbar = GridFunctions.getExcelStyleSearchComponentScrollbar(fix);
6595-
await wait();
6596-
fix.detectChanges();
6597-
6598-
// Get the display container and its parent and verify that the display container is at start
6599-
const displayContainer = searchComponent.querySelector('igx-display-container');
6600-
const displayContainerRect = displayContainer.getBoundingClientRect();
6601-
const parentContainerRect = displayContainer.parentElement.getBoundingClientRect();
6602-
6603-
expect(displayContainerRect.top - parentContainerRect.top <= 1).toBe(true, 'search scrollbar did not reset');
6600+
expect(scrollbar.scrollTop).toBe(0, 'search scrollbar did not reset');
66046601
});
66056602
});
66066603

0 commit comments

Comments
 (0)