Close colour picker when clicked outside

This commit is contained in:
Jiiks 2018-02-28 07:41:57 +02:00
parent fab7371d66
commit e418964819
2 changed files with 9 additions and 1 deletions

1
.gitignore vendored
View File

@ -23,3 +23,4 @@ Installers/**/*/packages
dist/
user.config.json
tests/data
/tests/themes/SimplerFlat

View File

@ -9,7 +9,7 @@
*/
<template>
<div class="bd-form-colourpicker">
<div ref="root" class="bd-form-colourpicker">
<div class="bd-title">
<h3 v-if="setting.text">{{setting.text}}</h3>
<div class="bd-colourpicker-wrapper">
@ -59,10 +59,17 @@
methods: {
pick(c) {
this.change(this.rgbaString);
},
closePopup(e) {
if (!this.$refs.root.contains(e.target)) this.open = false;
}
},
beforeMount() {
this.colors = this.setting.value;
window.addEventListener('click', this.closePopup);
},
destroyed() {
window.removeEventListener('click', this.closePopup);
},
watch: {
setting(newVal, oldVal) {