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

IgniteUI / igniteui-angular / 18975792037

31 Oct 2025 02:35PM UTC coverage: 91.603% (+0.004%) from 91.599%
18975792037

push

github

web-flow
Merge pull request #16380 from IgniteUI/mtihova/fix-16293-master

Prevent TypeError when accessing selection.keys() in certain environments

13890 of 16294 branches covered (85.25%)

1 of 1 new or added line in 1 file covered. (100.0%)

2 existing lines in 1 file now uncovered.

27883 of 30439 relevant lines covered (91.6%)

34576.75 hits per line

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

90.91
/projects/igniteui-angular/src/lib/directives/button/button-base.ts
1
import {
2
    Directive,
3
    ElementRef,
4
    EventEmitter,
5
    HostBinding,
6
    HostListener,
7
    Input,
8
    Output,
9
    booleanAttribute,
10
    inject,
11
    AfterViewInit,
12
} from '@angular/core';
13
import { PlatformUtil } from '../../core/utils';
14

15
export const IgxBaseButtonType = {
3✔
16
    Flat: 'flat',
17
    Contained: 'contained',
18
    Outlined: 'outlined'
19
} as const;
20

21

22
@Directive()
23
export abstract class IgxButtonBaseDirective implements AfterViewInit{
3✔
24
    private _platformUtil = inject(PlatformUtil);
11,150✔
25
    private _viewInit = false;
11,150✔
26

27
    /**
28
     * Emitted when the button is clicked.
29
     */
30
    @Output()
31
    public buttonClick = new EventEmitter<any>();
11,150✔
32

33
    /**
34
     * Sets/gets the `role` attribute.
35
     *
36
     * @example
37
     * ```typescript
38
     * this.button.role = 'navbutton';
39
     * let buttonRole = this.button.role;
40
     * ```
41
     */
42
    @HostBinding('attr.role')
43
    public role = 'button';
11,150✔
44

45
    /**
46
     * @hidden
47
     * @internal
48
     */
49
    @HostListener('click', ['$event'])
50
    public onClick(ev: MouseEvent) {
51
        this.buttonClick.emit(ev);
415✔
52
        this.focused = false;
415✔
53
    }
54

55
    /**
56
     * @hidden
57
     * @internal
58
     */
59
    @HostListener('blur')
60
    protected onBlur() {
61
        this.focused = false;
49✔
62
    }
63

64
    /**
65
     * Sets/gets whether the button component is on focus.
66
     * Default value is `false`.
67
     * ```typescript
68
     * this.button.focus = true;
69
     * ```
70
     * ```typescript
71
     * let isFocused =  this.button.focused;
72
     * ```
73
     */
74
    @HostBinding('class.igx-button--focused')
75
    protected focused = false;
11,150✔
76

77
    /**
78
      * Enables/disables the button.
79
      *
80
      * @example
81
      * ```html
82
      * <button igxButton="fab" disabled></button>
83
      * ```
84
      */
85
    @Input({ transform: booleanAttribute })
86
    @HostBinding('class.igx-button--disabled')
87
    public disabled = false;
11,150✔
88

89
    /**
90
     * @hidden
91
     * @internal
92
     */
93
    @HostBinding('attr.disabled')
94
    public get disabledAttribute() {
95
        return this.disabled || null;
161,599✔
96
    }
97

98
    protected constructor(
99
        public element: ElementRef,
11,150✔
100
    ) {
101
        // In browser, set via native API for immediate effect (no-op on server).
102
        // In SSR there is no paint, so there’s no visual rendering or transitions to suppress.
103
        // Fix style flickering https://github.com/IgniteUI/igniteui-angular/issues/14759
104
        if (this._platformUtil.isBrowser) {
11,150✔
105
            this.element.nativeElement.style.setProperty('--_init-transition', '0s');
11,150✔
106
        }
107
    }
108

109
    public ngAfterViewInit(): void {
110
        if (this._platformUtil.isBrowser && !this._viewInit) {
11,150✔
111
            this._viewInit = true;
11,150✔
112

113
            requestAnimationFrame(() => {
11,150✔
114
                this.element.nativeElement.style.removeProperty('--_init-transition');
11,150✔
115
            });
116
        }
117
    }
118

119
    /**
120
     * @hidden
121
     * @internal
122
     */
123
    @HostListener('keyup', ['$event'])
124
    protected updateOnKeyUp(event: KeyboardEvent) {
UNCOV
125
        if (event.key === "Tab") {
×
UNCOV
126
            this.focused = true;
×
127
        }
128
    }
129

130
    /**
131
     * Returns the underlying DOM element.
132
     */
133
    public get nativeElement() {
134
        return this.element.nativeElement;
898✔
135
    }
136
}
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