Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] IMEがONの場合に変換確定時のEnterで登録されてしまう点の修正 #4

Merged
merged 1 commit into from Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/app/component/todo-detail/todo-detail.component.html
@@ -1,6 +1,15 @@
<div>
<input type="text" [(ngModel)]="todo.task" (keyup.enter)="add()"
autofocus placeholder="add todo">
<input type="checkbox" [(ngModel)]="todo.done">
<input
type="text"
[(ngModel)]="todo.task"
(keydown)="keyDownCode = $event.which"
(keyup.enter)="handleKeyUp($event)"
autofocus
placeholder="add todo">

<input
type="checkbox"
[(ngModel)]="todo.done">

<button (click)="add()">add</button>
</div>
7 changes: 7 additions & 0 deletions src/app/component/todo-detail/todo-detail.component.ts
Expand Up @@ -10,13 +10,20 @@ export class TodoDetailComponent implements OnInit {

todo: Todo = new Todo;

keyDownCode: number;

@Output() clickAdd = new EventEmitter<Todo>();

constructor() { }

ngOnInit() {
}

handleKeyUp(e: KeyboardEvent) {
if (e.which !== this.keyDownCode) { return; }
this.add();
}

add() {
this.clickAdd.emit(this.todo);
this.todo = new Todo;
Expand Down