diff --git a/src/components/macro/action-editor/tab/delay/macro-delay.component.html b/src/components/macro/action-editor/tab/delay/macro-delay.component.html index 3b45d463..cc055a52 100644 --- a/src/components/macro/action-editor/tab/delay/macro-delay.component.html +++ b/src/components/macro/action-editor/tab/delay/macro-delay.component.html @@ -12,15 +12,15 @@ max="1000" step="0.1" placeholder="Delay amount" - class="form-control" - [(ngModel)]="delay" - (ngModelChange)="setDelay($event)"> + class="form-control" + [attr.value]="delay" + (change)="setDelay($event)">
Choose a preset
- +
diff --git a/src/components/macro/action-editor/tab/delay/macro-delay.component.ts b/src/components/macro/action-editor/tab/delay/macro-delay.component.ts index f43385b1..57218fae 100644 --- a/src/components/macro/action-editor/tab/delay/macro-delay.component.ts +++ b/src/components/macro/action-editor/tab/delay/macro-delay.component.ts @@ -1,4 +1,11 @@ -import { AfterViewInit, Component, ElementRef, Input, OnInit, Renderer, ViewChild } from '@angular/core'; +import { + ChangeDetectionStrategy, + Component, + ElementRef, + Input, + OnInit, + ViewChild +} from '@angular/core'; import { EditableMacroAction } from '../../../../../config-serializer/config-items/macro-action'; @@ -8,26 +15,24 @@ const INITIAL_DELAY = 0.5; // In seconds selector: 'macro-delay-tab', template: require('./macro-delay.component.html'), styles: [require('./macro-delay.component.scss')], - host: { 'class': 'macro__delay' } + host: { 'class': 'macro__delay' }, + changeDetection: ChangeDetectionStrategy.OnPush }) -export class MacroDelayTabComponent implements AfterViewInit, OnInit { +export class MacroDelayTabComponent implements OnInit { @Input() macroAction: EditableMacroAction; @ViewChild('macroDelayInput') input: ElementRef; + private delay: number; /* tslint:disable:no-unused-variable: It is used in the template. */ private presets: number[] = [0.3, 0.5, 0.8, 1, 2, 3, 4, 5]; /* tslint:enable:no-unused-variable */ - constructor(private renderer: Renderer) { } + constructor() { } ngOnInit() { this.delay = this.macroAction.delay > 0 ? this.macroAction.delay / 1000 : INITIAL_DELAY; } - ngAfterViewInit() { - this.renderer.invokeElementMethod(this.input.nativeElement, 'focus'); - } - setDelay(value: number): void { this.delay = value; this.macroAction.delay = this.delay * 1000;