8000 fix: do not emit update:value in case of 'multiple' attribute #64 · rasponline/coreui-vue@73d2b3f · GitHub
[go: up one dir, main page]

Skip to content

Commit 73d2b3f

Browse files
committed
fix: do not emit update:value in case of 'multiple' attribute coreui#64
1 parent 67f7cef commit 73d2b3f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/components/form/CSelect.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ export default {
220220
221221
methods: {
222222
onSelect (e) {
223+
if (this.$attrs.multiple !== undefined) return
223224
const optionIndex = e.target.selectedOptions[0].dataset.key
224225
const option = this.options[optionIndex]
225226
const value = option.value || option

src/components/form/tests/CSelect.spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ const customWrapper = mount(Component, {
4242
prepend: 'prepended'
4343
}
4444
})
45+
const wrapperMultiple = mount(Component, {
46+
propsData: {
47+
options: ['Option 1', 'Option 2', 'Option 3'],
48+
},
49+
attrs: {
50+
multiple: true
51+
}
52+
})
4553

4654
describe(ComponentName, () => {
4755
it('has a name', () => {
@@ -62,4 +70,10 @@ describe(ComponentName, () => {
6270
select.trigger('input')
6371
expect(customWrapper.emitted()['update:value']).toBeTruthy()
6472
})
73+
it('not emit update event on multiple select', () => {
74+
const select = wrapperMultiple.find('select')
75+
select.element.value = 'Option 2'
76+
select.trigger('input')
77+
expect(wrapperMultiple.emitted()['update:value']).not.toBeTruthy()
78+
})
6579
})

0 commit comments

Comments
 (0)
0