Capture Enter key event in inline edit
This commit is contained in:
parent
a89d473e62
commit
79ffd00074
@ -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>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user