2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-05-17 02:29:37 +03:00

WIP: adds a watcher for this.open, listens for touch events

This commit is contained in:
Jeff
2019-03-22 12:28:11 -07:00
parent 822187f436
commit 62a711ee23
+25
View File
@@ -806,6 +806,31 @@
*/
multiple(val) {
this.mutableValue = val ? [] : null
},
/**
* Ensure that iOS closes the dropdown when
* touch events occur outside the element.
*
* @see https://github.com/sagalbot/vue-select/issues/738
* @param isOpen
*/
open(isOpen) {
/**
* @param event {TouchEvent}
* @return {boolean}
*/
const touchAway = event => {
if( isOpen && !this.$el.contains(event.target) ) {
this.$refs.search.blur();
}
};
if (isOpen) {
return document.addEventListener('touchend', touchAway);
} else {
return document.removeEventListener('touchend', touchAway);
}
}
},