Fixes issue where save tag is called twice because of blur + enter. Make enter blur instead, calls it only once. Calling it twice results in issue where dummy note is deleted, creating invalid interface state

This commit is contained in:
Mo Bitar
2018-05-16 23:33:39 -05:00
parent 5be3c5eab3
commit 1c9616c573
3 changed files with 9 additions and 7 deletions

View File

@@ -144,11 +144,11 @@ angular.module('app')
}
$scope.tagsSelectionMade = function(tag) {
$scope.selectedTag = tag;
if($scope.selectedNote && $scope.selectedNote.dummy) {
modelManager.removeItemLocally($scope.selectedNote);
}
$scope.selectedTag = tag;
}
$scope.tagsAddNew = function(tag) {

View File

@@ -129,10 +129,12 @@ angular.module('app')
return;
}
this.save()(tag, function(savedTag){
this.selectTag(tag);
this.newTag = null;
}.bind(this));
this.save()(tag, (savedTag) => {
$timeout(() => {
this.selectTag(tag);
this.newTag = null;
})
});
}
function inputElementForTag(tag) {

View File

@@ -18,7 +18,7 @@
.tag{"ng-repeat" => "tag in ctrl.tags track by tag.uuid", "ng-click" => "ctrl.selectTag(tag)", "ng-class" => "{'selected' : ctrl.selectedTag == tag}"}
.info
%input.title{"ng-attr-id" => "tag-{{tag.uuid}}", "ng-click" => "ctrl.selectTag(tag)", "ng-model" => "tag.title",
"ng-keyup" => "$event.keyCode == 13 && ctrl.saveTag($event, tag)", "sn-autofocus" => "true", "should-focus" => "ctrl.newTag || ctrl.editingTag == tag",
"ng-keyup" => "$event.keyCode == 13 && $event.target.blur()", "sn-autofocus" => "true", "should-focus" => "ctrl.newTag || ctrl.editingTag == tag",
"ng-change" => "ctrl.tagTitleDidChange(tag)", "ng-blur" => "ctrl.saveTag($event, tag)", "spellcheck" => "false"}
.count {{ctrl.noteCount(tag)}}