• 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

53.33
/projects/igniteui-angular/src/lib/directives/focus/focus.directive.ts
1
import { Directive, ElementRef, Input, Optional, Inject, Self, booleanAttribute } from '@angular/core';
2
import { NG_VALUE_ACCESSOR } from '@angular/forms';
3
import { EditorProvider, EDITOR_PROVIDER } from '../../core/edit-provider';
4

5
@Directive({
6
    exportAs: 'igxFocus',
7
    selector: '[igxFocus]',
8
    standalone: true
9
})
10
export class IgxFocusDirective {
2✔
11

12
    private focusState = true;
80✔
13

14
    /**
15
     * Returns the state of the igxFocus.
16
     * ```typescript
17
     * @ViewChild('focusContainer', {read: IgxFocusDirective})
18
     * public igxFocus: IgxFocusDirective;
19
     * let isFocusOn = this.igxFocus.focused;
20
     * ```
21
     *
22
     * @memberof IgxFocusDirective
23
     */
24
    @Input({ alias: 'igxFocus', transform: booleanAttribute })
25
    public get focused(): boolean {
26
        return this.focusState;
×
27
    }
28

29
    /**
30
     * Sets the state of the igxFocus.
31
     * ```html
32
     * <igx-input-group >
33
     *  <input #focusContainer igxInput [igxFocus]="true"/>
34
     * </igx-input-group>
35
     * ```
36
     *
37
     * @memberof IgxFocusDirective
38
     */
39
    public set focused(val: boolean) {
40
        this.focusState = val;
80✔
41
        this.trigger();
80✔
42
    }
43

44
    /**
45
     * Gets the native element of the igxFocus.
46
     * ```typescript
47
     * @ViewChild('focusContainer', {read: IgxFocusDirective})
48
     * public igxFocus: IgxFocusDirective;
49
     * let igxFocusNativeElement = this.igxFocus.nativeElement;
50
     * ```
51
     *
52
     * @memberof IgxFocusDirective
53
     */
54
    public get nativeElement() {
UNCOV
55
        if (this.comp && this.comp[0] && this.comp[0].getEditElement) {
×
UNCOV
56
            return (this.comp[0] as EditorProvider).getEditElement();
×
57
        }
58

UNCOV
59
        if (this.control && this.control[0] && this.control[0].getEditElement) {
×
UNCOV
60
            return this.control[0].getEditElement();
×
61
        }
62

UNCOV
63
        return this.element.nativeElement;
×
64
    }
65

66
    constructor(
67
        private element: ElementRef,
80✔
68
        @Inject(NG_VALUE_ACCESSOR) @Self() @Optional() private comp?: any[],
80✔
69
        @Inject(EDITOR_PROVIDER) @Self() @Optional() private control?: any[],
80✔
70
    ) { }
71

72
    /**
73
     * Triggers the igxFocus state.
74
     * ```typescript
75
     * @ViewChild('focusContainer', {read: IgxFocusDirective})
76
     * public igxFocus: IgxFocusDirective;
77
     * this.igxFocus.trigger();
78
     * ```
79
     *
80
     * @memberof IgxFocusDirective
81
     */
82
    public trigger() {
83
        if (this.focusState) {
80!
UNCOV
84
            requestAnimationFrame(() => this.nativeElement.focus({ preventScroll: true }));
×
85
        }
86
    }
87
}
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