fix: user Renderer2 instead of deprecated Renderer (#844)

This commit is contained in:
Róbert Kiss
2018-10-30 03:06:44 +01:00
committed by László Monda
parent ca74b0a76b
commit 18808eae9c
4 changed files with 11 additions and 15 deletions

View File

@@ -4,7 +4,6 @@ import {
Component,
ElementRef,
Input,
Renderer,
ViewChild
} from '@angular/core';
import { TextMacroAction } from 'uhk-common';
@@ -23,14 +22,14 @@ export class MacroTextTabComponent extends MacroBaseComponent implements OnInit,
@Input() macroAction: TextMacroAction;
@ViewChild('macroTextInput') input: ElementRef;
constructor(private renderer: Renderer) { super(); }
constructor() { super(); }
ngOnInit() {
this.init();
}
ngAfterViewInit() {
this.renderer.invokeElementMethod(this.input.nativeElement, 'focus');
this.input.nativeElement.focus();
}
onTextChange() {

View File

@@ -1,5 +1,5 @@
import {
Component, ElementRef, EventEmitter, HostListener, Input, OnChanges, OnDestroy, OnInit, Output, Renderer,
Component, ElementRef, EventEmitter, HostListener, Input, OnChanges, OnDestroy, OnInit, Output,
SimpleChange, ChangeDetectionStrategy
} from '@angular/core';
import { animate, group, state, style, transition, trigger } from '@angular/animations';
@@ -110,8 +110,7 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
private mapper: MapperService,
private store: Store<AppState>,
private element: ElementRef,
private captureService: CaptureService,
private renderer: Renderer
private captureService: CaptureService
) {
this.subscription = store.let(getMacros())
.subscribe((macros: Macro[]) => this.macros = macros);
@@ -137,7 +136,7 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
onMouseDown(e: MouseEvent) {
if ((e.which === 2 || e.button === 2) && this.capturingEnabled) {
e.preventDefault();
this.renderer.invokeElementMethod(this.element.nativeElement, 'focus');
this.element.nativeElement.focus();
if (this.recording) {
this.reset();

View File

@@ -9,7 +9,6 @@ import {
OnChanges,
OnInit,
Output,
Renderer,
SimpleChanges,
ViewChild
} from '@angular/core';
@@ -100,8 +99,7 @@ export class SvgKeyboardWrapComponent implements OnInit, OnChanges {
constructor(
private store: Store<AppState>,
private mapper: MapperService,
private element: ElementRef,
private renderer: Renderer
private element: ElementRef
) {
this.keyEditConfig = {
moduleId: undefined,
@@ -216,7 +214,7 @@ export class SvgKeyboardWrapComponent implements OnInit, OnChanges {
this.keyPosition = this.keyElement.getBoundingClientRect();
this.popoverInitKeyAction = keyAction;
this.popoverShown = true;
this.renderer.invokeElementMethod(this.popover.nativeElement, 'focus');
this.popover.nativeElement.focus();
}
showTooltip(keyAction: KeyAction, event: MouseEvent): void {

View File

@@ -1,4 +1,4 @@
import { Directive, ElementRef, HostListener, Renderer } from '@angular/core';
import { Directive, ElementRef, HostListener, Renderer2 } from '@angular/core';
@Directive({
selector: '[cancelable]'
@@ -7,15 +7,15 @@ export class CancelableDirective {
private originalValue: string;
constructor(private elementRef: ElementRef, private renderer: Renderer) { }
constructor(private elementRef: ElementRef, private renderer: Renderer2) { }
@HostListener('focus') onFocus(): void {
this.originalValue = this.elementRef.nativeElement.value;
}
@HostListener('keyup.escape') onEscape(): void {
this.renderer.setElementProperty(this.elementRef.nativeElement, 'value', this.originalValue);
this.renderer.invokeElementMethod(this.elementRef.nativeElement, 'blur');
this.renderer.setProperty(this.elementRef.nativeElement, 'value', this.originalValue);
this.elementRef.nativeElement.blur();
}
}