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

IgniteUI / igniteui-angular / 20960087204

13 Jan 2026 02:19PM UTC coverage: 12.713% (-78.8%) from 91.5%
20960087204

Pull #16746

github

web-flow
Merge 9afce6e5d into a967f087e
Pull Request #16746: fix(csv): export summaries - master

1008 of 16803 branches covered (6.0%)

19 of 23 new or added lines in 2 files covered. (82.61%)

24693 existing lines in 336 files now uncovered.

3985 of 31345 relevant lines covered (12.71%)

2.49 hits per line

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

2.24
/projects/igniteui-angular/chips/src/chips/chip.component.ts
1
import {
2
    Component,
3
    ChangeDetectorRef,
4
    EventEmitter,
5
    ElementRef,
6
    HostBinding,
7
    HostListener,
8
    Input,
9
    Output,
10
    ViewChild,
11
    Renderer2,
12
    TemplateRef,
13
    OnDestroy,
14
    booleanAttribute,
15
    OnInit,
16
    inject,
17
    DOCUMENT
18
} from '@angular/core';
19
import { IgxDragDirective, IDragBaseEventArgs, IDragStartEventArgs, IDropBaseEventArgs, IDropDroppedEventArgs, IgxDropDirective } from 'igniteui-angular/directives';
20
import { IBaseEventArgs, ɵSize } from 'igniteui-angular/core';
21
import { ChipResourceStringsEN, IChipResourceStrings } from 'igniteui-angular/core';
22
import { Subject } from 'rxjs';
23
import { IgxIconComponent } from 'igniteui-angular/icon';
24
import { NgClass, NgTemplateOutlet } from '@angular/common';
25
import { getCurrentResourceStrings, onResourceChangeHandle } from 'igniteui-angular/core';
26

27
export const IgxChipTypeVariant = {
3✔
28
    PRIMARY: 'primary',
29
    INFO: 'info',
30
    SUCCESS: 'success',
31
    WARNING: 'warning',
32
    DANGER: 'danger'
33
} as const;
34
export type IgxChipTypeVariant = (typeof IgxChipTypeVariant)[keyof typeof IgxChipTypeVariant];
35

36
export interface IBaseChipEventArgs extends IBaseEventArgs {
37
    originalEvent: IDragBaseEventArgs | IDropBaseEventArgs | KeyboardEvent | MouseEvent | TouchEvent;
38
    owner: IgxChipComponent;
39
}
40

41
export interface IChipClickEventArgs extends IBaseChipEventArgs {
42
    cancel: boolean;
43
}
44

45
export interface IChipKeyDownEventArgs extends IBaseChipEventArgs {
46
    originalEvent: KeyboardEvent;
47
    cancel: boolean;
48
}
49

50
export interface IChipEnterDragAreaEventArgs extends IBaseChipEventArgs {
51
    dragChip: IgxChipComponent;
52
}
53

54
export interface IChipSelectEventArgs extends IBaseChipEventArgs {
55
    cancel: boolean;
56
    selected: boolean;
57
}
58

59
let CHIP_ID = 0;
3✔
60

61
/**
62
 * Chip is compact visual component that displays information in an obround.
63
 *
64
 * @igxModule IgxChipsModule
65
 *
66
 * @igxTheme igx-chip-theme
67
 *
68
 * @igxKeywords chip
69
 *
70
 * @igxGroup display
71
 *
72
 * @remarks
73
 * The Ignite UI Chip can be templated, deleted, and selected.
74
 * Multiple chips can be reordered and visually connected to each other.
75
 * Chips reside in a container called chips area which is responsible for managing the interactions between the chips.
76
 *
77
 * @example
78
 * ```html
79
 * <igx-chip class="chipStyle" [id]="901" [draggable]="true" [removable]="true" (remove)="chipRemoved($event)">
80
 *    <igx-avatar class="chip-avatar-resized" igxPrefix></igx-avatar>
81
 * </igx-chip>
82
 * ```
83
 */
84
@Component({
85
    selector: 'igx-chip',
86
    templateUrl: 'chip.component.html',
87
    imports: [IgxDropDirective, IgxDragDirective, NgClass, NgTemplateOutlet, IgxIconComponent]
88
})
89
export class IgxChipComponent implements OnInit, OnDestroy {
3✔
UNCOV
90
    public cdr = inject(ChangeDetectorRef);
×
UNCOV
91
    private ref = inject<ElementRef<HTMLElement>>(ElementRef);
×
UNCOV
92
    private renderer = inject(Renderer2);
×
UNCOV
93
    public document = inject(DOCUMENT);
×
94

95

96
    /**
97
     * Sets/gets the variant of the chip.
98
     *
99
     * @remarks
100
     * Allowed values are `primary`, `info`, `success`, `warning`, `danger`.
101
     * Providing no/nullish value leaves the chip in its default state.
102
     *
103
     * @example
104
     * ```html
105
     * <igx-chip variant="success"></igx-chip>
106
     * ```
107
     */
108
    @Input()
109
    public variant?: IgxChipTypeVariant | null;
110
    /**
111
     * Sets the value of `id` attribute. If not provided it will be automatically generated.
112
     *
113
     * @example
114
     * ```html
115
     * <igx-chip [id]="'igx-chip-1'"></igx-chip>
116
     * ```
117
     */
118
    @HostBinding('attr.id')
119
    @Input()
UNCOV
120
    public id = `igx-chip-${CHIP_ID++}`;
×
121

122
    /**
123
     * Returns the `role` attribute of the chip.
124
     *
125
     * @example
126
     * ```typescript
127
     * let chipRole = this.chip.role;
128
     * ```
129
     */
130
    @HostBinding('attr.role')
UNCOV
131
    public role = 'option';
×
132

133
    /**
134
     * Sets the value of `tabindex` attribute. If not provided it will use the element's tabindex if set.
135
     *
136
     * @example
137
     * ```html
138
     * <igx-chip [id]="'igx-chip-1'" [tabIndex]="1"></igx-chip>
139
     * ```
140
     */
141
    @HostBinding('attr.tabIndex')
142
    @Input()
143
    public set tabIndex(value: number) {
UNCOV
144
        this._tabIndex = value;
×
145
    }
146

147
    public get tabIndex() {
UNCOV
148
        if (this._tabIndex !== null) {
×
UNCOV
149
            return this._tabIndex;
×
150
        }
UNCOV
151
        return !this.disabled ? 0 : null;
×
152
    }
153

154
    /**
155
     * Stores data related to the chip.
156
     *
157
     * @example
158
     * ```html
159
     * <igx-chip [data]="{ value: 'Country' }"></igx-chip>
160
     * ```
161
     */
162
    @Input()
163
    public data: any;
164

165
    /**
166
     * Defines if the `IgxChipComponent` can be dragged in order to change it's position.
167
     * By default it is set to false.
168
     *
169
     * @example
170
     * ```html
171
     * <igx-chip [id]="'igx-chip-1'" [draggable]="true"></igx-chip>
172
     * ```
173
     */
174
    @Input({ transform: booleanAttribute })
UNCOV
175
    public draggable = false;
×
176

177
    /**
178
     * Enables/disables the draggable element animation when the element is released.
179
     * By default it's set to true.
180
     *
181
     * @example
182
     * ```html
183
     * <igx-chip [id]="'igx-chip-1'" [draggable]="true" [animateOnRelease]="false"></igx-chip>
184
     * ```
185
     */
186
    @Input({ transform: booleanAttribute })
UNCOV
187
    public animateOnRelease = true;
×
188

189
    /**
190
     * Enables/disables the hiding of the base element that has been dragged.
191
     * By default it's set to true.
192
     *
193
     * @example
194
     * ```html
195
     * <igx-chip [id]="'igx-chip-1'" [draggable]="true" [hideBaseOnDrag]="false"></igx-chip>
196
     * ```
197
     */
198
    @Input({ transform: booleanAttribute })
UNCOV
199
    public hideBaseOnDrag = true;
×
200

201
    /**
202
     * Defines if the `IgxChipComponent` should render remove button and throw remove events.
203
     * By default it is set to false.
204
     *
205
     * @example
206
     * ```html
207
     * <igx-chip [id]="'igx-chip-1'" [draggable]="true" [removable]="true"></igx-chip>
208
     * ```
209
     */
210
    @Input({ transform: booleanAttribute })
UNCOV
211
    public removable = false;
×
212

213
    /**
214
     * Overrides the default icon that the chip applies to the remove button.
215
     *
216
     * @example
217
     * ```html
218
     * <igx-chip [id]="chip.id" [removable]="true" [removeIcon]="iconTemplate"></igx-chip>
219
     * <ng-template #iconTemplate><igx-icon>delete</igx-icon></ng-template>
220
     * ```
221
     */
222
    @Input()
223
    public removeIcon: TemplateRef<any>;
224

225
    /**
226
     * Defines if the `IgxChipComponent` can be selected on click or through navigation,
227
     * By default it is set to false.
228
     *
229
     * @example
230
     * ```html
231
     * <igx-chip [id]="chip.id" [draggable]="true" [removable]="true" [selectable]="true"></igx-chip>
232
     * ```
233
     */
234
    @Input({ transform: booleanAttribute })
UNCOV
235
    public selectable = false;
×
236

237
    /**
238
     * Overrides the default icon that the chip applies when it is selected.
239
     *
240
     * @example
241
     * ```html
242
     * <igx-chip [id]="chip.id" [selectable]="true" [selectIcon]="iconTemplate"></igx-chip>
243
     * <ng-template #iconTemplate><igx-icon>done_outline</igx-icon></ng-template>
244
     * ```
245
     */
246
    @Input()
247
    public selectIcon: TemplateRef<any>;
248

249
    /**
250
     * @hidden
251
     * @internal
252
     */
253
    @Input()
UNCOV
254
    public class = '';
×
255

256
    /**
257
     * Disables the `IgxChipComponent`. When disabled it restricts user interactions
258
     * like focusing on click or tab, selection on click or Space, dragging.
259
     * By default it is set to false.
260
     *
261
     * @example
262
     * ```html
263
     * <igx-chip [id]="chip.id" [disabled]="true"></igx-chip>
264
     * ```
265
     */
266
    @HostBinding('class.igx-chip--disabled')
267
    @Input({ transform: booleanAttribute })
UNCOV
268
    public disabled = false;
×
269

270
    /**
271
     * Sets the `IgxChipComponent` selected state.
272
     *
273
     * @example
274
     * ```html
275
     * <igx-chip #myChip [id]="'igx-chip-1'" [selectable]="true" [selected]="true">
276
     * ```
277
     *
278
     * Two-way data binding:
279
     * ```html
280
     * <igx-chip #myChip [id]="'igx-chip-1'" [selectable]="true" [(selected)]="model.isSelected">
281
     * ```
282
     */
283
    @HostBinding('attr.aria-selected')
284
    @Input({ transform: booleanAttribute })
285
    public set selected(newValue: boolean) {
UNCOV
286
        this.changeSelection(newValue);
×
287
    }
288

289
    /**
290
     * Returns if the `IgxChipComponent` is selected.
291
     *
292
     * @example
293
     * ```typescript
294
     * @ViewChild('myChip')
295
     * public chip: IgxChipComponent;
296
     * selectedChip(){
297
     *     let selectedChip = this.chip.selected;
298
     * }
299
     * ```
300
     */
301
    public get selected() {
UNCOV
302
        return this._selected;
×
303
    }
304

305
    /**
306
     * @hidden
307
     * @internal
308
     */
309
    @Output()
UNCOV
310
    public selectedChange = new EventEmitter<boolean>();
×
311

312
    /**
313
     * Sets the `IgxChipComponent` background color.
314
     * The `color` property supports string, rgb, hex.
315
     *
316
     * @example
317
     * ```html
318
     * <igx-chip #myChip [id]="'igx-chip-1'" [color]="'#ff0000'"></igx-chip>
319
     * ```
320
     */
321
    @Input()
322
    public set color(newColor) {
UNCOV
323
        this.chipArea.nativeElement.style.backgroundColor = newColor;
×
324
    }
325

326
    /**
327
     * Returns the background color of the `IgxChipComponent`.
328
     *
329
     * @example
330
     * ```typescript
331
     * @ViewChild('myChip')
332
     * public chip: IgxChipComponent;
333
     * ngAfterViewInit(){
334
     *     let chipColor = this.chip.color;
335
     * }
336
     * ```
337
     */
338
    public get color() {
UNCOV
339
        return this.chipArea.nativeElement.style.backgroundColor;
×
340
    }
341

342
    /**
343
     * An accessor that sets the resource strings.
344
     * By default it uses EN resources.
345
     */
346
    @Input()
347
    public set resourceStrings(value: IChipResourceStrings) {
348
        this._resourceStrings = Object.assign({}, this._resourceStrings, value);
×
349
    }
350

351
    /**
352
     * An accessor that returns the resource strings.
353
     */
354
    public get resourceStrings(): IChipResourceStrings {
UNCOV
355
        return this._resourceStrings || this._defaultResourceStrings;
×
356
    }
357

358
    /**
359
     * Emits an event when the `IgxChipComponent` moving starts.
360
     * Returns the moving `IgxChipComponent`.
361
     *
362
     * @example
363
     * ```html
364
     * <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (moveStart)="moveStarted($event)">
365
     * ```
366
     */
367
    @Output()
UNCOV
368
    public moveStart = new EventEmitter<IBaseChipEventArgs>();
×
369

370
    /**
371
     * Emits an event when the `IgxChipComponent` moving ends.
372
     * Returns the moved `IgxChipComponent`.
373
     *
374
     * @example
375
     * ```html
376
     * <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (moveEnd)="moveEnded($event)">
377
     * ```
378
     */
379
    @Output()
UNCOV
380
    public moveEnd = new EventEmitter<IBaseChipEventArgs>();
×
381

382
    /**
383
     * Emits an event when the `IgxChipComponent` is removed.
384
     * Returns the removed `IgxChipComponent`.
385
     *
386
     * @example
387
     * ```html
388
     * <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (remove)="remove($event)">
389
     * ```
390
     */
391
    @Output()
UNCOV
392
    public remove = new EventEmitter<IBaseChipEventArgs>();
×
393

394
    /**
395
     * Emits an event when the `IgxChipComponent` is clicked.
396
     * Returns the clicked `IgxChipComponent`, whether the event should be canceled.
397
     *
398
     * @example
399
     * ```html
400
     * <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (click)="chipClick($event)">
401
     * ```
402
     */
403
    @Output()
UNCOV
404
    public chipClick = new EventEmitter<IChipClickEventArgs>();
×
405

406
    /**
407
     * Emits event when the `IgxChipComponent` is selected/deselected.
408
     * Returns the selected chip reference, whether the event should be canceled, what is the next selection state and
409
     * when the event is triggered by interaction `originalEvent` is provided, otherwise `originalEvent` is `null`.
410
     *
411
     * @example
412
     * ```html
413
     * <igx-chip #myChip [id]="'igx-chip-1'" [selectable]="true" (selectedChanging)="chipSelect($event)">
414
     * ```
415
     */
416
    @Output()
UNCOV
417
    public selectedChanging = new EventEmitter<IChipSelectEventArgs>();
×
418

419
    /**
420
     * Emits event when the `IgxChipComponent` is selected/deselected and any related animations and transitions also end.
421
     *
422
     * @example
423
     * ```html
424
     * <igx-chip #myChip [id]="'igx-chip-1'" [selectable]="true" (selectedChanged)="chipSelectEnd($event)">
425
     * ```
426
     */
427
    @Output()
UNCOV
428
    public selectedChanged = new EventEmitter<IBaseChipEventArgs>();
×
429

430
    /**
431
     * Emits an event when the `IgxChipComponent` keyboard navigation is being used.
432
     * Returns the focused/selected `IgxChipComponent`, whether the event should be canceled,
433
     * if the `alt`, `shift` or `control` key is pressed and the pressed key name.
434
     *
435
     * @example
436
     * ```html
437
     * <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (keyDown)="chipKeyDown($event)">
438
     * ```
439
     */
440
    @Output()
UNCOV
441
    public keyDown = new EventEmitter<IChipKeyDownEventArgs>();
×
442

443
    /**
444
     * Emits an event when the `IgxChipComponent` has entered the `IgxChipsAreaComponent`.
445
     * Returns the target `IgxChipComponent`, the drag `IgxChipComponent`, as  well as
446
     * the original drop event arguments.
447
     *
448
     * @example
449
     * ```html
450
     * <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (dragEnter)="chipEnter($event)">
451
     * ```
452
     */
453
    @Output()
UNCOV
454
    public dragEnter = new EventEmitter<IChipEnterDragAreaEventArgs>();
×
455

456
    /**
457
     * Emits an event when the `IgxChipComponent` has left the `IgxChipsAreaComponent`.
458
     * Returns the target `IgxChipComponent`, the drag `IgxChipComponent`, as  well as
459
     * the original drop event arguments.
460
     *
461
     * @example
462
     * ```html
463
     * <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (dragLeave)="chipLeave($event)">
464
     * ```
465
     */
466
    @Output()
UNCOV
467
    public dragLeave = new EventEmitter<IChipEnterDragAreaEventArgs>();
×
468

469
    /**
470
     * Emits an event when the `IgxChipComponent` is over the `IgxChipsAreaComponent`.
471
     * Returns the target `IgxChipComponent`, the drag `IgxChipComponent`, as  well as
472
     * the original drop event arguments.
473
     *
474
     * @example
475
     * ```html
476
     * <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (dragOver)="chipOver($event)">
477
     * ```
478
     */
479
    @Output()
UNCOV
480
    public dragOver = new EventEmitter<IChipEnterDragAreaEventArgs>();
×
481

482
    /**
483
     * Emits an event when the `IgxChipComponent` has been dropped in the `IgxChipsAreaComponent`.
484
     * Returns the target `IgxChipComponent`, the drag `IgxChipComponent`, as  well as
485
     * the original drop event arguments.
486
     *
487
     * @example
488
     * ```html
489
     * <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (dragDrop)="chipLeave($event)">
490
     * ```
491
     */
492
    @Output()
UNCOV
493
    public dragDrop = new EventEmitter<IChipEnterDragAreaEventArgs>();
×
494

495
    @HostBinding('class.igx-chip')
UNCOV
496
    protected defaultClass = 'igx-chip';
×
497

498
    @HostBinding('class.igx-chip--primary')
499
    protected get isPrimary() {
UNCOV
500
        return this.variant === IgxChipTypeVariant.PRIMARY;
×
501
    }
502

503
    @HostBinding('class.igx-chip--info')
504
    protected get isInfo() {
UNCOV
505
        return this.variant === IgxChipTypeVariant.INFO;
×
506
    }
507

508
    @HostBinding('class.igx-chip--success')
509
    protected get isSuccess() {
UNCOV
510
        return this.variant === IgxChipTypeVariant.SUCCESS;
×
511
    }
512

513
    @HostBinding('class.igx-chip--warning')
514
    protected get isWarning() {
UNCOV
515
        return this.variant === IgxChipTypeVariant.WARNING;
×
516
    }
517

518
    @HostBinding('class.igx-chip--danger')
519
    protected get isDanger() {
UNCOV
520
        return this.variant === IgxChipTypeVariant.DANGER;
×
521
    }
522

523
    /**
524
     * Property that contains a reference to the `IgxDragDirective` the `IgxChipComponent` uses for dragging behavior.
525
     *
526
     * @example
527
     * ```html
528
     * <igx-chip [id]="chip.id" [draggable]="true"></igx-chip>
529
     * ```
530
     * ```typescript
531
     * onMoveStart(event: IBaseChipEventArgs){
532
     *     let dragDirective = event.owner.dragDirective;
533
     * }
534
     * ```
535
     */
536
    @ViewChild('chipArea', { read: IgxDragDirective, static: true })
537
    public dragDirective: IgxDragDirective;
538

539
    /**
540
     * @hidden
541
     * @internal
542
     */
543
    @ViewChild('chipArea', { read: ElementRef, static: true })
544
    public chipArea: ElementRef;
545

546
    /**
547
     * @hidden
548
     * @internal
549
     */
550
    @ViewChild('defaultRemoveIcon', { read: TemplateRef, static: true })
551
    public defaultRemoveIcon: TemplateRef<any>;
552

553
    /**
554
     * @hidden
555
     * @internal
556
     */
557
    @ViewChild('defaultSelectIcon', { read: TemplateRef, static: true })
558
    public defaultSelectIcon: TemplateRef<any>;
559

560
    /**
561
     * @hidden
562
     * @internal
563
     */
564
    public get removeButtonTemplate() {
UNCOV
565
        if (!this.disabled) {
×
UNCOV
566
            return this.removeIcon || this.defaultRemoveIcon;
×
567
        }
568
    }
569

570
    /**
571
     * @hidden
572
     * @internal
573
     */
574
    public get selectIconTemplate() {
UNCOV
575
        return this.selectIcon || this.defaultSelectIcon;
×
576
    }
577

578
    /**
579
     * @hidden
580
     * @internal
581
     */
582
    public get ghostStyles() {
UNCOV
583
        return { '--ig-size': `${this.chipSize}` };
×
584
    }
585

586
    /** @hidden @internal */
587
    public get nativeElement() {
UNCOV
588
        return this.ref.nativeElement;
×
589
    }
590

591
    /**
592
     * @hidden
593
     * @internal
594
     */
UNCOV
595
    public hideBaseElement = false;
×
596

597
    /**
598
     * @hidden
599
     * @internal
600
     */
UNCOV
601
    public destroy$ = new Subject<void>();
×
602

603
    protected get chipSize(): ɵSize {
UNCOV
604
        return this.computedStyles?.getPropertyValue('--ig-size') || ɵSize.Medium;
×
605
    }
UNCOV
606
    protected _tabIndex = null;
×
UNCOV
607
    protected _selected = false;
×
UNCOV
608
    protected _selectedItemClass = 'igx-chip__item--selected';
×
UNCOV
609
    protected _movedWhileRemoving = false;
×
610
    protected computedStyles;
UNCOV
611
    private _resourceStrings: IChipResourceStrings = null;
×
UNCOV
612
    private _defaultResourceStrings = getCurrentResourceStrings(ChipResourceStringsEN);
×
613

614
    constructor() {
UNCOV
615
        onResourceChangeHandle(this.destroy$, () => {
×
UNCOV
616
            this._defaultResourceStrings = getCurrentResourceStrings(ChipResourceStringsEN, false);
×
617
        }, this);
618
    }
619

620
    /**
621
     * @hidden
622
     * @internal
623
     */
624
    @HostListener('keydown', ['$event'])
625
    public keyEvent(event: KeyboardEvent) {
UNCOV
626
        this.onChipKeyDown(event);
×
627
    }
628

629
    /**
630
     * @hidden
631
     * @internal
632
     */
633
    public selectClass(condition: boolean): any {
UNCOV
634
        const SELECT_CLASS = 'igx-chip__select';
×
635

UNCOV
636
        return {
×
637
            [SELECT_CLASS]: condition,
638
            [`${SELECT_CLASS}--hidden`]: !condition
639
        };
640
    }
641

642
    public onSelectTransitionDone(event) {
643
        if (event.target.tagName) {
×
644
            // Trigger onSelectionDone on when `width` property is changed and the target is valid element(not comment).
645
            this.selectedChanged.emit({
×
646
                owner: this,
647
                originalEvent: event
648
            });
649
        }
650
    }
651

652
    /**
653
     * @hidden
654
     * @internal
655
     */
656
    public onChipKeyDown(event: KeyboardEvent) {
UNCOV
657
        const keyDownArgs: IChipKeyDownEventArgs = {
×
658
            originalEvent: event,
659
            owner: this,
660
            cancel: false
661
        };
662

UNCOV
663
        this.keyDown.emit(keyDownArgs);
×
UNCOV
664
        if (keyDownArgs.cancel) {
×
665
            return;
×
666
        }
667

UNCOV
668
        if ((event.key === 'Delete' || event.key === 'Del') && this.removable) {
×
UNCOV
669
            this.remove.emit({
×
670
                originalEvent: event,
671
                owner: this
672
            });
673
        }
674

UNCOV
675
        if ((event.key === ' ' || event.key === 'Spacebar') && this.selectable && !this.disabled) {
×
UNCOV
676
            this.changeSelection(!this.selected, event);
×
677
        }
678

UNCOV
679
        if (event.key !== 'Tab') {
×
UNCOV
680
            event.preventDefault();
×
681
        }
682
    }
683

684
    /**
685
     * @hidden
686
     * @internal
687
     */
688
    public onRemoveBtnKeyDown(event: KeyboardEvent) {
UNCOV
689
        if (event.key === ' ' || event.key === 'Spacebar' || event.key === 'Enter') {
×
UNCOV
690
            this.remove.emit({
×
691
                originalEvent: event,
692
                owner: this
693
            });
694

UNCOV
695
            event.preventDefault();
×
UNCOV
696
            event.stopPropagation();
×
697
        }
698
    }
699

700
    public onRemoveMouseDown(event: PointerEvent | MouseEvent) {
UNCOV
701
        event.stopPropagation();
×
702
    }
703

704
    /**
705
     * @hidden
706
     * @internal
707
     */
708
    public onRemoveClick(event: MouseEvent | TouchEvent) {
UNCOV
709
        this.remove.emit({
×
710
            originalEvent: event,
711
            owner: this
712
        });
713
    }
714

715
    /**
716
     * @hidden
717
     * @internal
718
     */
719
    public onRemoveTouchMove() {
720
        // We don't remove chip if user starting touch interacting on the remove button moves the chip
721
        this._movedWhileRemoving = true;
×
722
    }
723

724
    /**
725
     * @hidden
726
     * @internal
727
     */
728
    public onRemoveTouchEnd(event: TouchEvent) {
729
        if (!this._movedWhileRemoving) {
×
730
            this.onRemoveClick(event);
×
731
        }
732
        this._movedWhileRemoving = false;
×
733
    }
734

735
    /**
736
     * @hidden
737
     * @internal
738
     */
739
    // -----------------------------
740
    // Start chip igxDrag behavior
741
    public onChipDragStart(event: IDragStartEventArgs) {
UNCOV
742
        this.moveStart.emit({
×
743
            originalEvent: event,
744
            owner: this
745
        });
UNCOV
746
        event.cancel = !this.draggable || this.disabled;
×
747
    }
748

749
    /**
750
     * @hidden
751
     * @internal
752
     */
753
    public onChipDragEnd() {
UNCOV
754
        if (this.animateOnRelease) {
×
755
            this.dragDirective.transitionToOrigin();
×
756
        }
757
    }
758

759
    /**
760
     * @hidden
761
     * @internal
762
     */
763
    public onChipMoveEnd(event: IDragBaseEventArgs) {
764
        // moveEnd is triggered after return animation has finished. This happen when we drag and release the chip.
UNCOV
765
        this.moveEnd.emit({
×
766
            originalEvent: event,
767
            owner: this
768
        });
769

UNCOV
770
        if (this.selected) {
×
771
            this.chipArea.nativeElement.focus();
×
772
        }
773
    }
774

775
    /**
776
     * @hidden
777
     * @internal
778
     */
779
    public onChipGhostCreate() {
UNCOV
780
        this.hideBaseElement = this.hideBaseOnDrag;
×
781
    }
782

783
    /**
784
     * @hidden
785
     * @internal
786
     */
787
    public onChipGhostDestroy() {
UNCOV
788
        this.hideBaseElement = false;
×
789
    }
790

791
    /**
792
     * @hidden
793
     * @internal
794
     */
795
    public onChipDragClicked(event: IDragBaseEventArgs) {
UNCOV
796
        const clickEventArgs: IChipClickEventArgs = {
×
797
            originalEvent: event,
798
            owner: this,
799
            cancel: false
800
        };
UNCOV
801
        this.chipClick.emit(clickEventArgs);
×
802

UNCOV
803
        if (!clickEventArgs.cancel && this.selectable && !this.disabled) {
×
UNCOV
804
            this.changeSelection(!this.selected, event);
×
805
        }
806
    }
807
    // End chip igxDrag behavior
808

809
    /**
810
     * @hidden
811
     * @internal
812
     */
813
    // -----------------------------
814
    // Start chip igxDrop behavior
815
    public onChipDragEnterHandler(event: IDropBaseEventArgs) {
UNCOV
816
        if (this.dragDirective === event.drag) {
×
817
            return;
×
818
        }
819

UNCOV
820
        const eventArgs: IChipEnterDragAreaEventArgs = {
×
821
            owner: this,
822
            dragChip: event.drag.data?.chip,
823
            originalEvent: event
824
        };
UNCOV
825
        this.dragEnter.emit(eventArgs);
×
826
    }
827

828
    /**
829
     * @hidden
830
     * @internal
831
     */
832
    public onChipDragLeaveHandler(event: IDropBaseEventArgs) {
UNCOV
833
        if (this.dragDirective === event.drag) {
×
834
            return;
×
835
        }
836

UNCOV
837
        const eventArgs: IChipEnterDragAreaEventArgs = {
×
838
            owner: this,
839
            dragChip: event.drag.data?.chip,
840
            originalEvent: event
841
        };
UNCOV
842
        this.dragLeave.emit(eventArgs);
×
843
    }
844

845
    /**
846
     * @hidden
847
     * @internal
848
     */
849
    public onChipDrop(event: IDropDroppedEventArgs) {
850
        // Cancel the default drop logic
UNCOV
851
        event.cancel = true;
×
UNCOV
852
        if (this.dragDirective === event.drag) {
×
853
            return;
×
854
        }
855

UNCOV
856
        const eventArgs: IChipEnterDragAreaEventArgs = {
×
857
            owner: this,
858
            dragChip: event.drag.data?.chip,
859
            originalEvent: event
860
        };
UNCOV
861
        this.dragDrop.emit(eventArgs);
×
862
    }
863

864
    /**
865
     * @hidden
866
     * @internal
867
     */
868
    public onChipOverHandler(event: IDropBaseEventArgs) {
UNCOV
869
        if (this.dragDirective === event.drag) {
×
870
            return;
×
871
        }
872

UNCOV
873
        const eventArgs: IChipEnterDragAreaEventArgs = {
×
874
            owner: this,
875
            dragChip: event.drag.data?.chip,
876
            originalEvent: event
877
        };
UNCOV
878
        this.dragOver.emit(eventArgs);
×
879
    }
880
    // End chip igxDrop behavior
881

882
    protected changeSelection(newValue: boolean, srcEvent = null) {
×
UNCOV
883
        const onSelectArgs: IChipSelectEventArgs = {
×
884
            originalEvent: srcEvent,
885
            owner: this,
886
            selected: false,
887
            cancel: false
888
        };
889

UNCOV
890
        if (newValue && !this._selected) {
×
UNCOV
891
            onSelectArgs.selected = true;
×
UNCOV
892
            this.selectedChanging.emit(onSelectArgs);
×
893

UNCOV
894
            if (!onSelectArgs.cancel) {
×
UNCOV
895
                this.renderer.addClass(this.chipArea.nativeElement, this._selectedItemClass);
×
UNCOV
896
                this._selected = newValue;
×
UNCOV
897
                this.selectedChange.emit(this._selected);
×
UNCOV
898
                this.selectedChanged.emit({
×
899
                    owner: this,
900
                    originalEvent: srcEvent
901
                });
902
            }
UNCOV
903
        } else if (!newValue && this._selected) {
×
UNCOV
904
            this.selectedChanging.emit(onSelectArgs);
×
905

UNCOV
906
            if (!onSelectArgs.cancel) {
×
UNCOV
907
                this.renderer.removeClass(this.chipArea.nativeElement, this._selectedItemClass);
×
UNCOV
908
                this._selected = newValue;
×
UNCOV
909
                this.selectedChange.emit(this._selected);
×
UNCOV
910
                this.selectedChanged.emit({
×
911
                    owner: this,
912
                    originalEvent: srcEvent
913
                });
914
            }
915
        }
916
    }
917

918
    public ngOnInit(): void {
UNCOV
919
        this.computedStyles = this.document.defaultView.getComputedStyle(this.nativeElement);
×
920
    }
921

922
    public ngOnDestroy(): void {
UNCOV
923
        this.destroy$.next();
×
UNCOV
924
        this.destroy$.complete();
×
925
    }
926
}
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