Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(MdSelect): add md-selected event #1234

Merged
merged 6 commits into from
Nov 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions docs/app/pages/Components/Select/Select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,19 @@
events: {
headings: ['Name', 'Description', 'Value'],
props: [
{
name: 'md-selected',
description: 'Triggered when model changes.',
value: 'Value of v-model'
},
{
name: 'md-opened',
description: 'Triggered when the select is opened.',
description: 'Triggered when select is opened.',
value: 'none'
},
{
name: 'md-closed',
description: 'Triggered when the select is closed.',
description: 'Triggered when select is closed.',
value: 'none'
}
]
Expand Down
10 changes: 7 additions & 3 deletions src/components/MdField/MdSelect/MdSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,14 @@
let includes = index > -1
if (!includes) {
this.localValue = this.localValue.concat([value])
return
} else {
this.localValue = this.arrayAccessorRemove(this.localValue, index)
}
this.localValue = this.arrayAccessorRemove(this.localValue, index)
this.emitSelected(this.localValue)
},
setValue (newValue) {
this.model = newValue
this.emitSelected(newValue)
this.setFieldValue()
this.showSelect = false
},
Expand All @@ -227,7 +229,6 @@
},
setMultipleValue (value) {
const newValue = value

this.toggleArrayValue(newValue)
this.setFieldValue()
},
Expand Down Expand Up @@ -264,6 +265,9 @@
if (!this.multiple && isArray) {
this.localValue = this.localValue.length > 0 ? this.localValue[0] : null
}
},
emitSelected (value) {
this.$emit('md-selected', value)
}
},
async mounted () {
Expand Down