Fix: hide colorpicker on mousedown

This commit is contained in:
eight 2017-12-06 03:11:23 +08:00
parent 31535fb7b3
commit 181d9206d9

View File

@ -9,6 +9,8 @@ function configDialog(style) {
const elements = [];
const colorpicker = window.colorpicker();
document.addEventListener('mousedown', onMouseDown);
buildConfigForm();
renderValues();
@ -29,6 +31,7 @@ function configDialog(style) {
t('confirmCancel')
]
}).then(({button, esc}) => {
document.removeEventListener('mousedown', onMouseDown);
if (button !== 1) {
colorpicker.hide();
}
@ -194,4 +197,10 @@ function configDialog(style) {
window.addEventListener('keydown', messageBox.listeners.key, true);
}
}
function onMouseDown(e) {
if (!e.target.closest('.colorpicker-popup')) {
colorpicker.hide();
}
}
}