• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IgniteUI / igniteui-angular / 17149271404

22 Aug 2025 07:38AM UTC coverage: 91.576% (-0.004%) from 91.58%
17149271404

push

github

web-flow
Merge pull request #16109 from IgniteUI/ikitanov/fix-16091

DateRangePicker - Add cancel button in dialog mode

13632 of 15972 branches covered (85.35%)

11 of 11 new or added lines in 2 files covered. (100.0%)

207 existing lines in 8 files now uncovered.

27461 of 29987 relevant lines covered (91.58%)

34342.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.43
/projects/igniteui-angular/src/lib/grids/headers/grid-header-row.component.ts
1
import {
2
    ChangeDetectionStrategy,
3
    ChangeDetectorRef,
4
    Component,
5
    DoCheck,
6
    ElementRef,
7
    HostBinding,
8
    Input,
9
    QueryList,
10
    TemplateRef,
11
    ViewChild,
12
    ViewChildren,
13
    booleanAttribute
14
} from '@angular/core';
15
import { flatten, trackByIdentity } from '../../core/utils';
16
import { IgxGridForOfDirective } from '../../directives/for-of/for_of.directive';
17
import { ColumnType, GridType, IgxHeadSelectorTemplateContext } from '../common/grid.interface';
18
import { IgxGridFilteringCellComponent } from '../filtering/base/grid-filtering-cell.component';
19
import { IgxGridFilteringRowComponent } from '../filtering/base/grid-filtering-row.component';
20
import { IgxGridHeaderGroupComponent } from './grid-header-group.component';
21
import { IgxGridHeaderComponent } from './grid-header.component';
22
import { IgxHeaderGroupWidthPipe, IgxHeaderGroupStylePipe } from './pipes';
23
import { IgxGridTopLevelColumns } from '../common/pipes';
24
import { IgxCheckboxComponent } from '../../checkbox/checkbox.component';
25
import { IgxColumnMovingDropDirective } from '../moving/moving.drop.directive';
26
import { NgTemplateOutlet, NgClass, NgStyle } from '@angular/common';
27

28
/**
29
 *
30
 * For all intents & purposes treat this component as what a <thead> usually is in the default <table> element.
31
 *
32
 * This container holds the grid header elements and their behavior/interactions.
33
 *
34
 * @hidden @internal
35
 */
36
@Component({
37
    changeDetection: ChangeDetectionStrategy.OnPush,
38
    selector: 'igx-grid-header-row',
39
    templateUrl: './grid-header-row.component.html',
40
    imports: [IgxColumnMovingDropDirective, NgTemplateOutlet, NgClass, IgxGridHeaderGroupComponent, NgStyle, IgxGridForOfDirective, IgxGridFilteringRowComponent, IgxCheckboxComponent, IgxGridTopLevelColumns, IgxHeaderGroupWidthPipe, IgxHeaderGroupStylePipe]
41
})
42
export class IgxGridHeaderRowComponent implements DoCheck {
3✔
43

44
    /** The grid component containing this element. */
45
    @Input()
46
    public grid: GridType;
47

48
    /** Pinned columns of the grid at start. */
49
    @Input()
50
    public pinnedStartColumnCollection: ColumnType[] = [];
5,247✔
51

52
    /** Pinned columns of the grid at end. */
53
    @Input()
54
    public pinnedEndColumnCollection: ColumnType[] = [];
5,247✔
55

56

57
    /** Unpinned columns of the grid. */
58
    @Input()
59
    public unpinnedColumnCollection: ColumnType[] = [];
5,247✔
60

61
    @HostBinding('attr.aria-activedescendant')
62
    public get activeDescendant() {
63
        const activeElem = this.navigation.activeNode;
59,994✔
64

65
        if (!activeElem || !Object.keys(activeElem).length || activeElem.row >= 0) {
59,994✔
66
            return null;
58,606✔
67
        }
68
        return `${this.grid.id}_${activeElem.row}_${activeElem.level}_${activeElem.column}`;
1,388✔
69
    }
70

71
    @Input({ transform: booleanAttribute })
72
    public hasMRL: boolean;
73

74
    @Input()
75
    public width: number;
76

77
    /**
78
     * Header groups inside the header row.
79
     *
80
     * @remarks
81
     * Note: These are only the top level header groups in case there are multi-column headers
82
     * or a specific column layout. If you want to get the flattened collection use the `groups`
83
     * property below.
84
     *
85
     * @hidden @internal
86
     * */
87
    @ViewChildren(IgxGridHeaderGroupComponent)
88
    public _groups: QueryList<IgxGridHeaderGroupComponent>;
89

90
    /**
91
     * The flattened header groups collection.
92
     *
93
     * @hidden @internal
94
     */
95
    public get groups(): IgxGridHeaderGroupComponent[] {
96
        return flatten(this._groups?.toArray() ?? []);
20,824✔
97
    }
98

99
    /** Header components in the header row. */
100
    public get headers(): IgxGridHeaderComponent[] {
101
        return this.groups.map(group => group.header);
×
102
    }
103

104
    /** Filtering cell components in the header row. */
105
    public get filters(): IgxGridFilteringCellComponent[] {
UNCOV
106
        return this.groups.map(group => group.filter);
×
107
    }
108

109
    /**
110
     * Gets a list of all visible leaf columns in the grid.
111
     *
112
     * @hidden @internal
113
     */
114
    public get visibleLeafColumns(): ColumnType[] {
115
        const row = this.grid.gridAPI.get_row_by_index(this.grid.rowList.first?.index || 0);
7,252✔
116
        if (row && row.cells) {
7,252✔
117
            return row.cells.map(cell => cell.column);
26,241✔
118
        }
119
    }
120

121
    /**
122
    * @hidden
123
    * @internal
124
    */
125
    public get isLeafHeaderAriaHidden(): boolean {
126
        return this.grid.navigation.activeNode.row === -1;
26,241✔
127
    }
128

129
    /** The virtualized part of the header row containing the unpinned header groups. */
130
    @ViewChild('headerVirtualContainer', { read: IgxGridForOfDirective, static: true })
131
    public headerContainer: IgxGridForOfDirective<ColumnType, ColumnType[]>;
132

133
    public get headerForOf() {
134
        return this.headerContainer;
14,402✔
135
    }
136

137
    @ViewChild('headerDragContainer')
138
    public headerDragContainer: ElementRef<HTMLElement>;
139

140
    @ViewChild('headerSelectorContainer')
141
    public headerSelectorContainer: ElementRef<HTMLElement>;
142

143
    @ViewChild('headerGroupContainer')
144
    public headerGroupContainer: ElementRef<HTMLElement>;
145

146
    @ViewChild('headSelectorBaseTemplate')
147
    public headSelectorBaseTemplate: TemplateRef<IgxHeadSelectorTemplateContext>;
148

149
    @ViewChild(IgxGridFilteringRowComponent)
150
    public filterRow: IgxGridFilteringRowComponent;
151

152
    /**
153
     * Expand/collapse all child grids area in a hierarchical grid.
154
     * `undefined` in the base and tree grids.
155
     *
156
     * @internal @hidden
157
     */
158
    @ViewChild('headerHierarchyExpander')
159
    public headerHierarchyExpander: ElementRef<HTMLElement>;
160

161
    public get navigation() {
162
        return this.grid.navigation;
64,594✔
163
    }
164

165
    public get nativeElement() {
166
        return this.ref.nativeElement;
11,152✔
167
    }
168

169
    /**
170
     * Returns whether the current grid instance is a hierarchical grid.
171
     * as only hierarchical grids have the `isHierarchicalRecord` method.
172
     *
173
     * @hidden @internal
174
     */
175
    public get isHierarchicalGrid() {
176
        return !!this.grid.isHierarchicalRecord;
46,093✔
177
    }
178

179
    public get indentationCSSClasses() {
180
        return `igx-grid__header-indentation igx-grid__row-indentation--level-${this.grid.groupingExpressions.length}`;
2,180✔
181
    }
182

183
    public get rowSelectorsContext(): IgxHeadSelectorTemplateContext {
184
        const ctx = {
3,331✔
185
            $implicit: {
186
                selectedCount: this.grid.selectionService.filteredSelectedRowIds.length as number,
187
                totalCount: this.grid.totalRowsCountAfterFilter as number
188
            }
189
        } as IgxHeadSelectorTemplateContext;
190

191
        if (this.isHierarchicalGrid) {
3,331✔
192
            ctx.$implicit.selectAll = () => this.grid.selectAllRows();
1,124✔
193
            ctx.$implicit.deselectAll = () => this.grid.deselectAllRows();
1,124✔
194
        }
195

196
        return ctx;
3,331✔
197
    }
198

199
    constructor(
200
        protected ref: ElementRef<HTMLElement>,
5,247✔
201
        protected cdr: ChangeDetectorRef
5,247✔
202
    ) { }
203

204
    /**
205
     * This hook exists as a workaround for the unfortunate fact
206
     * that when we have pinned columns in the grid, the unpinned columns headers
207
     * are affected by a delayed change detection cycle after a horizontal scroll :(
208
     * Thus, we tell the parent grid change detector to check us at each cycle.
209
     *
210
     * @hidden @internal
211
     */
212
    public ngDoCheck() {
213
        this.cdr.markForCheck();
61,867✔
214
    }
215

216
    /**
217
     * @hidden @internal
218
     */
219
    public scroll(event: Event) {
UNCOV
220
        this.grid.preventHeaderScroll(event);
×
221
    }
222

223
    public headerRowSelection(event: MouseEvent) {
224
        if (!this.grid.isMultiRowSelectionEnabled) {
45✔
225
            return;
7✔
226
        }
227

228
        if (this.grid.selectionService.areAllRowSelected()) {
38✔
229
            this.grid.selectionService.clearRowSelection(event);
12✔
230
        } else {
231
            this.grid.selectionService.selectAllRows(event);
26✔
232
        }
233
    }
234

235
    /** state persistence switching all pinned columns resets collection */
236
    protected trackPinnedColumn = trackByIdentity;
5,247✔
237
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc