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

IgniteUI / igniteui-angular / 13331632524

14 Feb 2025 02:51PM CUT coverage: 22.015% (-69.6%) from 91.622%
13331632524

Pull #15372

github

web-flow
Merge d52d57714 into bcb78ae0a
Pull Request #15372: chore(*): test ci passing

1990 of 15592 branches covered (12.76%)

431 of 964 new or added lines in 18 files covered. (44.71%)

19956 existing lines in 307 files now uncovered.

6452 of 29307 relevant lines covered (22.02%)

249.17 hits per line

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

42.86
/projects/igniteui-angular/src/lib/directives/text-selection/text-selection.directive.ts
1
import { Directive, ElementRef, HostListener, Input, booleanAttribute } from '@angular/core';
2

3
@Directive({
4
    exportAs: 'igxTextSelection',
5
    selector: '[igxTextSelection]',
6
    standalone: true
7
})
8
export class IgxTextSelectionDirective {
2✔
9
    /**
10
     *  Determines whether the input element could be selected through the directive.
11
     *
12
     * ```html
13
     * <!--set-->
14
     * <input
15
     *   type="text"
16
     *   id="firstName"
17
     *   [igxTextSelection]="true">
18
     * </input>
19
     *
20
     * <input
21
     *   type="text"
22
     *   id="lastName"
23
     *   igxTextSelection
24
     *   [selected]="true">
25
     * </input>
26
     * ```
27
     */
28
    @Input({ alias: 'igxTextSelection', transform: booleanAttribute })
29
    public selected = true;
2✔
30

31
    /**
32
     * Returns the nativeElement of the element where the directive was applied.
33
     *
34
     * ```html
35
     * <input
36
     *   type="text"
37
     *   id="firstName"
38
     *   igxTextSelection>
39
     * </input>
40
     * ```
41
     *
42
     * ```typescript
43
     * @ViewChild('firstName',
44
     *  {read: IgxTextSelectionDirective})
45
     * public inputElement: IgxTextSelectionDirective;
46
     *
47
     * public getNativeElement() {
48
     *  return this.inputElement.nativeElement;
49
     * }
50
     * ```
51
     */
52
    public get nativeElement() {
UNCOV
53
        return this.element.nativeElement;
×
54
    }
55

56
    constructor(private element: ElementRef) { }
2✔
57

58
    /**
59
     * @hidden
60
     */
61
    @HostListener('focus')
62
    public onFocus() {
UNCOV
63
        this.trigger();
×
64
    }
65

66
    /**
67
     * Triggers the selection of the element if it is marked as selectable.
68
     *
69
     * ```html
70
     * <input
71
     *   type="text"
72
     *   id="firstName"
73
     *   igxTextSelection>
74
     * </input>
75
     * ```
76
     *
77
     * ```typescript
78
     * @ViewChild('firstName',
79
     *  {read: IgxTextSelectionDirective})
80
     * public inputElement: IgxTextSelectionDirective;
81
     *
82
     * public triggerElementSelection() {
83
     *  this.inputElement.trigger();
84
     * }
85
     * ```
86
     */
87

88
    public trigger() {
UNCOV
89
        if (this.selected && this.nativeElement.value.length) {
×
90
            // delay the select call to avoid race conditions in case the directive is applied
91
            // to an element with its own focus handler
UNCOV
92
            requestAnimationFrame(() => this.nativeElement.select());
×
93
        }
94
    }
95
}
96

97
/**
98
 * @hidden
99
 */
100

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

© 2025 Coveralls, Inc