Skip to content

Commit

Permalink
notify embedder on closing colorpicker
Browse files Browse the repository at this point in the history
fixup 7fea2cf: messageBox's Esc handler wasn't restored
  • Loading branch information
tophf committed Sep 6, 2018
1 parent 373fe5f commit 26d7c26
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions vendor-overwrites/colorpicker/colorpicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,9 @@
}
}

function hide({notify = true} = {}) {
function hide() {
if (shown) {
if (notify) {
colorpickerCallback('');
}
colorpickerCallback('');
unregisterEvents();
focusNoScroll(prevFocusedElement);
$root.remove();
Expand Down Expand Up @@ -623,7 +621,7 @@
case 27:
e.preventDefault();
e.stopPropagation();
hide({notify: false});
hide();
break;
}
}
Expand All @@ -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);
}
}
}

Expand Down

0 comments on commit 26d7c26

Please sign in to comment.