mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-19 09:50:33 +03:00
- move mutableLoading data property to ajax mixin
- open dropdown only when not loading - add watcher to keep loading synced with mutableLoading
This commit is contained in:
@@ -488,8 +488,7 @@
|
|||||||
search: '',
|
search: '',
|
||||||
open: false,
|
open: false,
|
||||||
mutableValue: null,
|
mutableValue: null,
|
||||||
mutableOptions: [],
|
mutableOptions: []
|
||||||
mutableLoading: false
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -765,7 +764,7 @@
|
|||||||
* @return {Boolean} True if open
|
* @return {Boolean} True if open
|
||||||
*/
|
*/
|
||||||
dropdownOpen() {
|
dropdownOpen() {
|
||||||
return this.noDrop ? false : this.open
|
return this.noDrop ? false : this.open && !this.mutableLoading
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,6 +27,12 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
mutableLoading: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
/**
|
/**
|
||||||
* If a callback & search text has been provided,
|
* If a callback & search text has been provided,
|
||||||
@@ -38,6 +44,14 @@ module.exports = {
|
|||||||
this.$emit('search', this.search, this.toggleLoading)
|
this.$emit('search', this.search, this.toggleLoading)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Sync the loading prop with the internal
|
||||||
|
* mutable loading value.
|
||||||
|
* @param val
|
||||||
|
*/
|
||||||
|
loading(val) {
|
||||||
|
this.mutableLoading = val
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -1058,6 +1058,18 @@ describe('Select.vue', () => {
|
|||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('will sync mutable loading with the loading prop', (done) => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<div><v-select ref="select" :loading="loading"></v-select></div>',
|
||||||
|
data: {loading:false}
|
||||||
|
}).$mount()
|
||||||
|
vm.loading = true
|
||||||
|
Vue.nextTick(() => {
|
||||||
|
expect(vm.$refs.select.mutableLoading).toEqual(true)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Reset on options change', () => {
|
describe('Reset on options change', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user