Skip to content

Commit 378a36f

Browse files
author
georgii.rychko
committed
fix: apply new node value on blur (fixes #4)
1 parent 5732a92 commit 378a36f

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

src/editable/node-editable.directive.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,19 @@ export class NodeEditableDirective implements OnInit {
3434

3535
@HostListener('keyup.enter', ['$event.target.value'])
3636
private applyNewValue(newNodeValue: string) {
37-
return this.valueChanged.emit({type: 'keyup', value: newNodeValue});
37+
this.valueChanged.emit({type: 'keyup', value: newNodeValue});
3838
}
3939

40-
@HostListener('keyup.esc')
41-
private cancelEditing() {
42-
return this.valueChanged.emit({
43-
type: 'keyup',
44-
value: this.nodeValue,
45-
action: NodeEditableEventAction.Cancel
46-
});
40+
@HostListener('blur', ['$event.target.value'])
41+
private applyNewValueByLoosingFocus(newNodeValue: string): void {
42+
this.valueChanged.emit({type: 'blur', value: newNodeValue});
4743
}
4844

49-
@HostListener('blur')
50-
private cancelEditingByLoosingFocus() {
45+
@HostListener('keyup.esc')
46+
private cancelEditing(): void {
5147
this.valueChanged.emit({
52-
type: 'blur',
53-
value: this.nodeValue,
48+
type: 'keyup',
49+
value: this.nodeValue,
5450
action: NodeEditableEventAction.Cancel
5551
});
5652
}

0 commit comments

Comments
 (0)