Skip to content

Commit fe1c281

Browse files
Fix bug where input field would not write inputs if the current string is empty
1 parent f0ecd74 commit fe1c281

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

projects/angular-keyboard/src/lib/fake-input/fake-input.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
(click)="onClickInputField($event)">
55
<ng-container *ngFor="let char of chars; let idx = index">
66
<tb-fake-char #fakechar
7-
(clickLeft)="onClickCharLeft(char, idx)"
8-
(clickRight)="onClickCharRight(char, idx)"
9-
[char]="char"
10-
[cursor]="getCursor(idx)"></tb-fake-char>
7+
(clickLeft)="onClickCharLeft(char, idx)"
8+
(clickRight)="onClickCharRight(char, idx)"
9+
[char]="char"
10+
[cursor]="getCursor(idx)"></tb-fake-char>
1111
</ng-container>
1212
</div>

projects/angular-keyboard/src/lib/fake-input/fake-input.component.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ interface Cursor {
3939
export class FakeInputComponent implements OnInit, OnDestroy {
4040

4141
@Input() suggestionMode = false;
42-
@Input () initialText = '';
42+
@Input() initialText = '';
4343

4444
@Output() text = new EventEmitter();
4545

@@ -467,16 +467,18 @@ export class FakeInputComponent implements OnInit, OnDestroy {
467467
onClickInputField(e) {
468468
this.focusInput();
469469
const closest = this.findClosestHorizontalChar(e);
470-
if (closest.isLeft) {
471-
this.cursor = {
472-
index: closest.idx,
473-
side: Side.LEFT
474-
};
475-
} else {
476-
this.cursor = {
477-
index: closest.idx,
478-
side: Side.RIGHT
479-
};
470+
if (closest != null) {
471+
if (closest.isLeft) {
472+
this.cursor = {
473+
index: closest.idx,
474+
side: Side.LEFT
475+
};
476+
} else {
477+
this.cursor = {
478+
index: closest.idx,
479+
side: Side.RIGHT
480+
};
481+
}
480482
}
481483
}
482484

0 commit comments

Comments
 (0)