Skip to content

Commit 84a16ea

Browse files
committed
Don't trigger on focus if already visible and on blur if nothing changed
1 parent 246a687 commit 84a16ea

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

examples/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ angular
1212
});
1313

1414
$scope.onColorChange = function($event, color) {
15-
console.log($event, color);
15+
console.log($event, color, $scope.color);
1616
}
1717
});

lib/scripts/directive.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,10 @@
143143
};
144144

145145
$scope.onBlur = function() {
146-
$scope.updateModel = true;
147-
$scope.update();
146+
if ($scope.ngModel !== $scope.onChangeValue) {
147+
$scope.updateModel = true;
148+
$scope.update();
149+
}
148150
};
149151

150152
$scope.initConfig = function() {
@@ -171,6 +173,11 @@
171173
};
172174

173175
$scope.show = function () {
176+
// if already visible then don't run show again
177+
if ($scope.visible) {
178+
return true;
179+
}
180+
174181
$scope.log('Color Picker: Show Event');
175182
$scope.visible = true;
176183
$scope.hueMouse = false;

0 commit comments

Comments
 (0)