From 26d7c2677069ff0fdef28d288aea32a0c0de237f Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 6 Sep 2018 19:33:10 +0300 Subject: [PATCH] notify embedder on closing colorpicker fixup 7fea2cfc: messageBox's Esc handler wasn't restored --- vendor-overwrites/colorpicker/colorpicker.js | 21 ++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/vendor-overwrites/colorpicker/colorpicker.js b/vendor-overwrites/colorpicker/colorpicker.js index 2617b5e9..38f4af75 100644 --- a/vendor-overwrites/colorpicker/colorpicker.js +++ b/vendor-overwrites/colorpicker/colorpicker.js @@ -222,11 +222,9 @@ } } - function hide({notify = true} = {}) { + function hide() { if (shown) { - if (notify) { - colorpickerCallback(''); - } + colorpickerCallback(''); unregisterEvents(); focusNoScroll(prevFocusedElement); $root.remove(); @@ -623,7 +621,7 @@ case 27: e.preventDefault(); e.stopPropagation(); - hide({notify: false}); + hide(); break; } } @@ -643,17 +641,20 @@ //region Event utilities function colorpickerCallback(colorString = currentColorToString()) { - // Esc pressed? - if (!colorString) { + const isCallable = typeof options.callback === 'function'; + // hiding + if (!colorString && isCallable) { options.callback(''); + return; } if ( userActivity && - $inputs[currentFormat].every(el => el.checkValidity()) && - typeof options.callback === 'function' + $inputs[currentFormat].every(el => el.checkValidity()) ) { lastOutputColor = colorString.replace(/\b0\./g, '.'); - options.callback(lastOutputColor); + if (isCallable) { + options.callback(lastOutputColor); + } } }