fix #247: data loss on exit with focused field

This commit is contained in:
antelle 2016-08-21 21:38:18 +03:00
parent 3c5392a072
commit 6fe7d129b1
2 changed files with 10 additions and 5 deletions

View File

@ -33,7 +33,7 @@ var FieldViewText = FieldView.extend({
click: this.fieldValueInputClick.bind(this), click: this.fieldValueInputClick.bind(this),
mousedown: this.fieldValueInputMouseDown.bind(this) mousedown: this.fieldValueInputMouseDown.bind(this)
}); });
this.listenTo(Backbone, 'click', this.fieldValueBlur); this.listenTo(Backbone, 'click main-window-will-close', this.fieldValueBlur);
if (this.model.multiline) { if (this.model.multiline) {
this.setInputHeight(); this.setInputHeight();
} }
@ -130,15 +130,15 @@ var FieldViewText = FieldView.extend({
this.hideGenerator(); this.hideGenerator();
return; return;
} }
this.stopListening(Backbone, 'click', this.fieldValueBlur); this.stopBlurListener();
this.endEdit(e.target.value); this.endEdit(e.target.value);
} }
} else if (code === Keys.DOM_VK_ESCAPE) { } else if (code === Keys.DOM_VK_ESCAPE) {
this.stopListening(Backbone, 'click', this.fieldValueBlur); this.stopBlurListener();
this.endEdit(); this.endEdit();
} else if (code === Keys.DOM_VK_TAB) { } else if (code === Keys.DOM_VK_TAB) {
e.preventDefault(); e.preventDefault();
this.stopListening(Backbone, 'click', this.fieldValueBlur); this.stopBlurListener();
this.endEdit(e.target.value, { tab: { field: this.model.name, prev: e.shiftKey } }); this.endEdit(e.target.value, { tab: { field: this.model.name, prev: e.shiftKey } });
} else if (code === Keys.DOM_VK_G && e.metaKey) { } else if (code === Keys.DOM_VK_G && e.metaKey) {
e.preventDefault(); e.preventDefault();
@ -154,7 +154,7 @@ var FieldViewText = FieldView.extend({
return; return;
} }
delete this.input; delete this.input;
this.stopListening(Backbone, 'click', this.fieldValueBlur); this.stopBlurListener();
if (typeof newVal === 'string' && this.value instanceof kdbxweb.ProtectedValue) { if (typeof newVal === 'string' && this.value instanceof kdbxweb.ProtectedValue) {
newVal = kdbxweb.ProtectedValue.fromString(newVal); newVal = kdbxweb.ProtectedValue.fromString(newVal);
} }
@ -164,6 +164,10 @@ var FieldViewText = FieldView.extend({
FieldView.prototype.endEdit.call(this, newVal, extra); FieldView.prototype.endEdit.call(this, newVal, extra);
}, },
stopBlurListener: function() {
this.stopListening(Backbone, 'click main-window-will-close', this.fieldValueBlur);
},
render: function() { render: function() {
FieldView.prototype.render.call(this); FieldView.prototype.render.call(this);
} }

View File

@ -21,6 +21,7 @@ Audit, generator presets, auto-type and ui improvements
`-` fix idle timer on computer sleep `-` fix idle timer on computer sleep
`-` fix storage popup when no action is required `-` fix storage popup when no action is required
`-` fix loading raw 32-byte and 64-byte keyfiles `-` fix loading raw 32-byte and 64-byte keyfiles
`-` fix data loss on exit with focused field
##### v1.2.4 (2016-07-20) ##### v1.2.4 (2016-07-20)
`+` digital signature in installer `+` digital signature in installer