Skip to content

Commit 4581d73

Browse files
authored
Merge pull request sagalbot#162 from sagalbot/fix-loading-regression
Fix loading regression
2 parents da12f96 + 546418d commit 4581d73

File tree

3 files changed

+56
-9
lines changed

3 files changed

+56
-9
lines changed

src/components/Select.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<style>
22
.v-select {
33
position: relative;
4+
font-family: sans-serif;
45
}
56
.v-select,
67
.v-select * {
78
-webkit-box-sizing: border-box;
89
-moz-box-sizing: border-box;
910
box-sizing: border-box;
10-
font-family: sans-serif;
1111
}
1212
/* Open Indicator */
1313
.v-select .open-indicator {
@@ -76,6 +76,7 @@
7676
cursor: pointer;
7777
}
7878
.v-select.open .dropdown-toggle {
79+
border-bottom-color: transparent;
7980
border-bottom-left-radius: 0;
8081
border-bottom-right-radius: 0;
8182
}
@@ -91,10 +92,12 @@
9192
width: 100%;
9293
overflow-y: scroll;
9394
border: 1px solid rgba(0, 0, 0, .26);
95+
box-shadow: 0px 3px 6px 0px rgba(0,0,0,.15);
9496
border-top: none;
9597
border-radius: 0 0 4px 4px;
9698
text-align: left;
9799
list-style: none;
100+
background: #fff;
98101
}
99102
.v-select .no-options {
100103
text-align: center;

src/mixins/ajax.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ module.exports = {
3333
* invoke the onSearch callback.
3434
*/
3535
search() {
36-
if (this.search.length > 0 && this.onSearch) {
36+
if (this.search.length > 0) {
3737
this.onSearch(this.search, this.toggleLoading)
38-
}
38+
this.$emit('search', this.search, this.toggleLoading)
39+
}
3940
},
4041
},
4142

@@ -49,9 +50,9 @@ module.exports = {
4950
*/
5051
toggleLoading(toggle = null) {
5152
if (toggle == null) {
52-
return this.showLoading = !this.showLoading
53+
return this.mutableLoading = !this.mutableLoading
5354
}
54-
return this.showLoading = toggle
55+
return this.mutableLoading = toggle
5556
}
5657
}
5758
}

test/unit/specs/Select.spec.js

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -931,10 +931,10 @@ describe('Select.vue', () => {
931931
}).$mount()
932932

933933
vm.$refs.select.toggleLoading()
934-
expect(vm.$refs.select.showLoading).toEqual(true)
934+
expect(vm.$refs.select.mutableLoading).toEqual(true)
935935

936936
vm.$refs.select.toggleLoading(true)
937-
expect(vm.$refs.select.showLoading).toEqual(true)
937+
expect(vm.$refs.select.mutableLoading).toEqual(true)
938938
})
939939

940940
it('should trigger the onSearch callback when the search text changes', (done) => {
@@ -980,6 +980,49 @@ describe('Select.vue', () => {
980980
})
981981
})
982982

983+
it('should trigger the search event when the search text changes', (done) => {
984+
const vm = new Vue({
985+
template: '<div><v-select ref="select" @search="foo"></v-select></div>',
986+
data: {
987+
called: false
988+
},
989+
methods: {
990+
foo(val) {
991+
this.called = val
992+
}
993+
}
994+
}).$mount()
995+
996+
vm.$refs.select.search = 'foo'
997+
998+
Vue.nextTick(() => {
999+
expect(vm.called).toEqual('foo')
1000+
done()
1001+
})
1002+
})
1003+
1004+
it('should not trigger the search event if the search text is empty', (done) => {
1005+
const vm = new Vue({
1006+
template: '<div><v-select ref="select" search="foo" @search="foo"></v-select></div>',
1007+
data: { called: false },
1008+
methods: {
1009+
foo(val) {
1010+
this.called = ! this.called
1011+
}
1012+
}
1013+
}).$mount()
1014+
1015+
vm.$refs.select.search = 'foo'
1016+
Vue.nextTick(() => {
1017+
expect(vm.called).toBe(true)
1018+
vm.$refs.select.search = ''
1019+
Vue.nextTick(() => {
1020+
expect(vm.called).toBe(true)
1021+
done()
1022+
})
1023+
})
1024+
})
1025+
9831026
it('can set loading to false from the onSearch callback', (done) => {
9841027
const vm = new Vue({
9851028
template: '<div><v-select loading ref="select" :on-search="foo"></v-select></div>',
@@ -992,7 +1035,7 @@ describe('Select.vue', () => {
9921035

9931036
vm.$refs.select.search = 'foo'
9941037
Vue.nextTick(() => {
995-
expect(vm.$refs.select.showLoading).toEqual(false)
1038+
expect(vm.$refs.select.mutableLoading).toEqual(false)
9961039
done()
9971040
})
9981041
})
@@ -1011,7 +1054,7 @@ describe('Select.vue', () => {
10111054
select.onSearch(select.search, select.toggleLoading)
10121055

10131056
Vue.nextTick(() => {
1014-
expect(vm.$refs.select.showLoading).toEqual(true)
1057+
expect(vm.$refs.select.mutableLoading).toEqual(true)
10151058
done()
10161059
})
10171060
})

0 commit comments

Comments
 (0)