mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-22 10:30:34 +03:00
Merge branch 'click-tag-to-toggle-dropdown' of https://github.com/stevenharman/vue-select into stevenharman-click-tag-to-toggle-dropdown
# Conflicts: # src/components/Select.vue
This commit is contained in:
@@ -874,7 +874,7 @@
|
|||||||
*/
|
*/
|
||||||
toggleDropdown(e) {
|
toggleDropdown(e) {
|
||||||
if (e.target === this.$refs.openIndicator || e.target === this.$refs.search || e.target === this.$refs.toggle ||
|
if (e.target === this.$refs.openIndicator || e.target === this.$refs.search || e.target === this.$refs.toggle ||
|
||||||
e.target === this.$refs.selectedOptions || e.target === this.$el) {
|
e.target.classList.contains('selected-tag') || e.target === this.$el) {
|
||||||
if (this.open) {
|
if (this.open) {
|
||||||
this.$refs.search.blur() // dropdown will close on blur
|
this.$refs.search.blur() // dropdown will close on blur
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -403,6 +403,26 @@ describe('Select.vue', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should open the dropdown when the selected tag is clicked', (done) => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<div><v-select :options="options" :value="value"></v-select></div>',
|
||||||
|
components: {vSelect},
|
||||||
|
data: {
|
||||||
|
value: [{label: 'one'}],
|
||||||
|
options: [{label: 'one'}]
|
||||||
|
}
|
||||||
|
}).$mount()
|
||||||
|
|
||||||
|
const selectedTag = vm.$children[0].$el.getElementsByClassName('selected-tag')[0]
|
||||||
|
vm.$children[0].toggleDropdown({target: selectedTag})
|
||||||
|
Vue.nextTick(() => {
|
||||||
|
Vue.nextTick(() => {
|
||||||
|
expect(vm.$children[0].open).toEqual(true)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it('can close the dropdown when the el is clicked', (done) => {
|
it('can close the dropdown when the el is clicked', (done) => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: '<div><v-select></v-select></div>',
|
template: '<div><v-select></v-select></div>',
|
||||||
|
|||||||
Reference in New Issue
Block a user