Skip to content

Commit 28dd68a

Browse files
detinhoshentao
authored andcommitted
Display selected zero value (shentao#801) (shentao#851)
1 parent 3a8e704 commit 28dd68a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Multiselect.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ export default {
290290
computed: {
291291
isSingleLabelVisible () {
292292
return (
293-
this.singleValue &&
293+
(this.singleValue || this.singleValue === 0) &&
294294
(!this.isOpen || !this.searchable) &&
295295
!this.visibleValues.length
296296
)

tests/unit/Multiselect.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,19 @@ describe('Multiselect.vue', () => {
15201520
})
15211521
expect(wrapper.vm.currentOptionLabel).toBe(0)
15221522
})
1523+
test('should display selected value even when is the number zero', () => {
1524+
const wrapper = shallowMount(Multiselect, {
1525+
propsData: {
1526+
value: 0,
1527+
options: [0, 1, 2, 3, 4, 5]
1528+
}
1529+
})
1530+
1531+
expect(wrapper.vm.isSingleLabelVisible).toBe(true)
1532+
expect(wrapper.find('.multiselect__single').text()).toContainEqual(
1533+
'0'
1534+
)
1535+
})
15231536
describe('when MULTIPLE is FALSE', () => {
15241537
test('should return the current option label', () => {
15251538
const wrapper = shallowMount(Multiselect, {

0 commit comments

Comments
 (0)