Allow for unselecting a color in the color picker

This commit is contained in:
Sebastiaan Janssen
2019-02-18 16:42:05 +01:00
parent 34216fd635
commit 817dd21155

View File

@@ -34,8 +34,17 @@ Use this directive to generate color swatches to pick from.
}
scope.setColor = function (color, $index, $event) {
scope.selectedColor = color;
if (scope.onSelect) {
// did the value change?
if (scope.selectedColor != null && scope.selectedColor.value === color.value) {
// User clicked the currently selected color
// to remove the selection, they don't want
// to select any color after all.
// Unselect the color
color = null;
}
scope.selectedColor = color;
scope.onSelect({color: color, $index: $index, $event: $event});
$event.stopPropagation();
}