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

IgniteUI / igniteui-angular / 13331632524

14 Feb 2025 02:51PM UTC 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

64.0
/projects/igniteui-angular/src/lib/drop-down/drop-down-item.component.ts
1
import {
2
    Component,
3
    HostBinding
4
} from '@angular/core';
5
import { IgxDropDownItemBaseDirective } from './drop-down-item.base';
6

7
/**
8
 * The `<igx-drop-down-item>` is a container intended for row items in
9
 * a `<igx-drop-down>` container.
10
 */
11
@Component({
12
    selector: 'igx-drop-down-item',
13
    templateUrl: 'drop-down-item.component.html',
14
    standalone: true
15
})
16
export class IgxDropDownItemComponent extends IgxDropDownItemBaseDirective {
2✔
17
    /**
18
     * Sets/gets if the given item is focused
19
     * ```typescript
20
     *  let mySelectedItem = this.dropdown.selectedItem;
21
     *  let isMyItemFocused = mySelectedItem.focused;
22
     * ```
23
     */
24
    public override get focused(): boolean {
25
        let focusedState = this._focused;
11,529✔
26
        if (this.hasIndex) {
11,529✔
27
            const focusedItem = this.selection.first_item(`${this.dropDown.id}-active`);
4,908✔
28
            const focusedIndex = focusedItem ? focusedItem.index : -1;
4,908!
29
            focusedState = this._index === focusedIndex;
4,908✔
30
        }
31
        return this.isSelectable && focusedState;
11,529✔
32
    }
33

34
    /**
35
     * Sets/gets if the given item is focused
36
     * ```typescript
37
     *  let mySelectedItem = this.dropdown.selectedItem;
38
     *  let isMyItemFocused = mySelectedItem.focused;
39
     * ```
40
     */
41
    public override set focused(value: boolean) {
42
        this._focused = value;
113✔
43
    }
44
    /**
45
     * Sets/Gets if the item is the currently selected one in the dropdown
46
     *
47
     * ```typescript
48
     *  let mySelectedItem = this.dropdown.selectedItem;
49
     *  let isMyItemSelected = mySelectedItem.selected; // true
50
     * ```
51
     *
52
     * Two-way data binding
53
     * ```html
54
     * <igx-drop-down-item [(selected)]='model.isSelected'></igx-drop-down-item>
55
     * ```
56
     */
57
    public override get selected(): boolean {
58
        if (this.hasIndex) {
2,664!
UNCOV
59
            const item = this.selection.first_item(`${this.dropDown.id}`);
×
UNCOV
60
            return item ? item.index === this._index && item.value === this.value : false;
×
61
        }
62
        return this._selected;
2,664✔
63
    }
64

65
    /**
66
     * Sets/Gets if the item is the currently selected one in the dropdown
67
     *
68
     */
69
    public override set selected(value: boolean) {
UNCOV
70
        if (this.isHeader) {
×
UNCOV
71
            return;
×
72
        }
UNCOV
73
        this._selected = value;
×
UNCOV
74
        this.selectedChange.emit(this._selected);
×
75
    }
76
    /**
77
     * @hidden @internal
78
     */
79
    @HostBinding('attr.tabindex')
80
    public get setTabIndex() {
81
        const shouldSetTabIndex = this.dropDown.allowItemsFocus && this.isSelectable;
11,529!
82
        if (shouldSetTabIndex) {
11,529!
UNCOV
83
            return 0;
×
84
        } else {
85
            return null;
11,529✔
86
        }
87
    }
88

89
    public override clicked(event): void {
90
        if (!this.isSelectable) {
37!
UNCOV
91
            this.ensureItemFocus();
×
UNCOV
92
            return;
×
93
        }
94
        if (this.selection) {
37✔
95
            this.dropDown.selectItem(this, event);
37✔
96
        }
97
    }
98
}
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