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

atinc / ngx-tethys / d9ae709b-3c27-4b69-b125-b8b80b54f90b

pending completion
d9ae709b-3c27-4b69-b125-b8b80b54f90b

Pull #2757

circleci

mengshuicmq
fix: fix code review
Pull Request #2757: feat(color-picker): color-picker support disabled (#INFR-8645)

98 of 6315 branches covered (1.55%)

Branch coverage included in aggregate %.

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

2392 of 13661 relevant lines covered (17.51%)

83.12 hits per line

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

23.81
/src/shared/directives/thy-autofocus.directive.ts
1
import { Directive, Input, ElementRef, NgZone } from '@angular/core';
2
import { InputBoolean, reqAnimFrame } from 'ngx-tethys/core';
3
import { coerceBooleanProperty } from 'ngx-tethys/util';
4

5
/**
6
 * 自动聚焦指令
7
 * @name input[thyAutofocus],textarea[thyAutofocus]
8
 */
9
@Directive({
1✔
10
    selector: 'input[thyAutofocus],textarea[thyAutofocus]',
11
    standalone: true
×
12
})
13
export class ThyAutofocusDirective {
14
    // 自动选择,用于只读的 input 输入框,方便复制粘贴
×
15
    private _autoSelect = false;
16

17
    /**
18
     * 是否自动聚焦
19
     * @default false
×
20
     */
×
21
    @Input()
×
22
    set thyAutofocus(value: boolean | string) {
×
23
        if (coerceBooleanProperty(value) !== false) {
24
            // Note: this is being run outside of the Angular zone because `element.focus()` doesn't require
25
            // running change detection.
26
            this.ngZone.runOutsideAngular(() =>
27
                // Note: `element.focus()` causes re-layout and this may lead to frame drop on slower devices.
28
                // https://gist.github.com/paulirish/5d52fb081b3570c81e3a#setting-focus
×
29
                // `setTimeout` is a macrotask and macrotasks are executed within the current rendering frame.
30
                // Animation tasks are executed within the next rendering frame.
31
                reqAnimFrame(() => {
×
32
                    this.elementRef.nativeElement.focus();
×
33
                    if (this._autoSelect && this.elementRef.nativeElement.select) {
34
                        this.elementRef.nativeElement.select();
×
35
                    }
36
                })
1✔
37
            );
38
        }
39
    }
40

1✔
41
    /**
42
     * 是否自动选择
43
     * @default false
44
     */
45
    @Input()
1✔
46
    @InputBoolean()
47
    set thyAutoSelect(value: boolean) {
48
        this._autoSelect = coerceBooleanProperty(value);
49
    }
50

1✔
51
    constructor(private elementRef: ElementRef, private ngZone: NgZone) {}
52
}
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