From 18808eae9c50040d4fb26a61b67d50bc8517421b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Kiss?= Date: Tue, 30 Oct 2018 03:06:44 +0100 Subject: [PATCH] fix: user Renderer2 instead of deprecated Renderer (#844) --- .../macro/action-editor/tab/text/macro-text.component.ts | 5 ++--- .../keys/svg-keyboard-key/svg-keyboard-key.component.ts | 7 +++---- .../components/svg/wrap/svg-keyboard-wrap.component.ts | 6 ++---- .../src/app/directives/cancelable/cancelable.directive.ts | 8 ++++---- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/packages/uhk-web/src/app/components/macro/action-editor/tab/text/macro-text.component.ts b/packages/uhk-web/src/app/components/macro/action-editor/tab/text/macro-text.component.ts index 367ec223..39c1343c 100644 --- a/packages/uhk-web/src/app/components/macro/action-editor/tab/text/macro-text.component.ts +++ b/packages/uhk-web/src/app/components/macro/action-editor/tab/text/macro-text.component.ts @@ -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() { diff --git a/packages/uhk-web/src/app/components/svg/keys/svg-keyboard-key/svg-keyboard-key.component.ts b/packages/uhk-web/src/app/components/svg/keys/svg-keyboard-key/svg-keyboard-key.component.ts index f33b29b8..2da2518a 100644 --- a/packages/uhk-web/src/app/components/svg/keys/svg-keyboard-key/svg-keyboard-key.component.ts +++ b/packages/uhk-web/src/app/components/svg/keys/svg-keyboard-key/svg-keyboard-key.component.ts @@ -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, 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(); diff --git a/packages/uhk-web/src/app/components/svg/wrap/svg-keyboard-wrap.component.ts b/packages/uhk-web/src/app/components/svg/wrap/svg-keyboard-wrap.component.ts index 7fc260f5..e0a31e60 100644 --- a/packages/uhk-web/src/app/components/svg/wrap/svg-keyboard-wrap.component.ts +++ b/packages/uhk-web/src/app/components/svg/wrap/svg-keyboard-wrap.component.ts @@ -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, 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 { diff --git a/packages/uhk-web/src/app/directives/cancelable/cancelable.directive.ts b/packages/uhk-web/src/app/directives/cancelable/cancelable.directive.ts index 13c2e131..12e647cc 100644 --- a/packages/uhk-web/src/app/directives/cancelable/cancelable.directive.ts +++ b/packages/uhk-web/src/app/directives/cancelable/cancelable.directive.ts @@ -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(); } }