Capture Enter key event in inline edit

This commit is contained in:
kiswa 2017-01-31 23:58:32 +00:00
parent a89d473e62
commit 79ffd00074
2 changed files with 9 additions and 2 deletions

View File

@ -6,7 +6,7 @@
</span>
<span [hidden]="isDisplay">
<input #editText type="text"
[value]="text" (keyup.enter)="editDone(editText.value)">
[value]="text" (keyup.enter)="editDone(editText.value, $event)">
<i class="icon icon-floppy color-primary" title="Save"
(click)="editDone(editText.value)"></i>
</span>

View File

@ -21,10 +21,17 @@ export class InlineEdit {
setTimeout(() => { el.focus(); }, 100);
}
editDone(newText: string): void {
editDone(newText: string, event: Event): void {
this.isDisplay = true;
this.text = newText;
this.edit.emit(this.text);
// Prevent Enter key from propagating to parent controls
if (event.stopPropagation) {
event.stopPropagation();
} else {
event.cancelBubble = true;
}
}
}