From 817dd21155f8ab4712955be648ecb19563f3765b Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 18 Feb 2019 16:42:05 +0100 Subject: [PATCH] Allow for unselecting a color in the color picker --- .../components/umbcolorswatches.directive.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbcolorswatches.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbcolorswatches.directive.js index 9401cacab1..d998504d1b 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbcolorswatches.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbcolorswatches.directive.js @@ -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(); }