From fe1c2814054d8ba965f2dab3bf97331b76bb9eb7 Mon Sep 17 00:00:00 2001 From: Anette-Hunziker Date: Wed, 22 Apr 2020 09:10:12 +0200 Subject: [PATCH] Fix bug where input field would not write inputs if the current string is empty --- .../lib/fake-input/fake-input.component.html | 8 +++---- .../lib/fake-input/fake-input.component.ts | 24 ++++++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/projects/angular-keyboard/src/lib/fake-input/fake-input.component.html b/projects/angular-keyboard/src/lib/fake-input/fake-input.component.html index 75fa2a8..b1897e7 100755 --- a/projects/angular-keyboard/src/lib/fake-input/fake-input.component.html +++ b/projects/angular-keyboard/src/lib/fake-input/fake-input.component.html @@ -4,9 +4,9 @@ (click)="onClickInputField($event)"> + (clickLeft)="onClickCharLeft(char, idx)" + (clickRight)="onClickCharRight(char, idx)" + [char]="char" + [cursor]="getCursor(idx)"> diff --git a/projects/angular-keyboard/src/lib/fake-input/fake-input.component.ts b/projects/angular-keyboard/src/lib/fake-input/fake-input.component.ts index 7a179a1..64aa398 100755 --- a/projects/angular-keyboard/src/lib/fake-input/fake-input.component.ts +++ b/projects/angular-keyboard/src/lib/fake-input/fake-input.component.ts @@ -39,7 +39,7 @@ interface Cursor { export class FakeInputComponent implements OnInit, OnDestroy { @Input() suggestionMode = false; - @Input () initialText = ''; + @Input() initialText = ''; @Output() text = new EventEmitter(); @@ -467,16 +467,18 @@ export class FakeInputComponent implements OnInit, OnDestroy { onClickInputField(e) { this.focusInput(); const closest = this.findClosestHorizontalChar(e); - if (closest.isLeft) { - this.cursor = { - index: closest.idx, - side: Side.LEFT - }; - } else { - this.cursor = { - index: closest.idx, - side: Side.RIGHT - }; + if (closest != null) { + if (closest.isLeft) { + this.cursor = { + index: closest.idx, + side: Side.LEFT + }; + } else { + this.cursor = { + index: closest.idx, + side: Side.RIGHT + }; + } } }