mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-22 10:30:34 +03:00
WIP: adds a watcher for this.open, listens for touch events
This commit is contained in:
@@ -806,6 +806,31 @@
|
|||||||
*/
|
*/
|
||||||
multiple(val) {
|
multiple(val) {
|
||||||
this.mutableValue = val ? [] : null
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user