notify embedder on closing colorpicker

fixup 7fea2cfc: messageBox's Esc handler wasn't restored
This commit is contained in:
tophf 2018-09-06 19:33:10 +03:00
parent 373fe5f510
commit 26d7c26770

View File

@ -222,11 +222,9 @@
} }
} }
function hide({notify = true} = {}) { function hide() {
if (shown) { if (shown) {
if (notify) { colorpickerCallback('');
colorpickerCallback('');
}
unregisterEvents(); unregisterEvents();
focusNoScroll(prevFocusedElement); focusNoScroll(prevFocusedElement);
$root.remove(); $root.remove();
@ -623,7 +621,7 @@
case 27: case 27:
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
hide({notify: false}); hide();
break; break;
} }
} }
@ -643,17 +641,20 @@
//region Event utilities //region Event utilities
function colorpickerCallback(colorString = currentColorToString()) { function colorpickerCallback(colorString = currentColorToString()) {
// Esc pressed? const isCallable = typeof options.callback === 'function';
if (!colorString) { // hiding
if (!colorString && isCallable) {
options.callback(''); options.callback('');
return;
} }
if ( if (
userActivity && userActivity &&
$inputs[currentFormat].every(el => el.checkValidity()) && $inputs[currentFormat].every(el => el.checkValidity())
typeof options.callback === 'function'
) { ) {
lastOutputColor = colorString.replace(/\b0\./g, '.'); lastOutputColor = colorString.replace(/\b0\./g, '.');
options.callback(lastOutputColor); if (isCallable) {
options.callback(lastOutputColor);
}
} }
} }