Skip to content

Commit

Permalink
Add create-tag prop to taginput
Browse files Browse the repository at this point in the history
  • Loading branch information
jtommy committed Jul 31, 2020
1 parent 04e4b18 commit c2a67ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions docs/pages/components/taginput/api/taginput.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ export default [
values: '—',
default: '<code>false</code>'
},
{
name: '<code>create-tag</code>',
description: 'Function to create tag item to push into v-model (tags)',
type: 'Function',
values: '—',
default: '<code>(tagToAdd) => tagToAdd</code>'
},
{
name: '<code>readonly</code>',
description: 'Disable input/typing',
Expand Down
6 changes: 5 additions & 1 deletion src/components/taginput/Taginput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ export default {
type: Boolean,
default: false
},
createTag: {
type: Function,
default: (tag) => tag
},
appendToBody: Boolean
},
data() {
Expand Down Expand Up @@ -267,7 +271,7 @@ export default {
// or previously added (if not allowDuplicates).
const add = !this.allowDuplicates ? this.tags.indexOf(tagToAdd) === -1 : true
if (add && this.beforeAdding(tagToAdd)) {
this.tags.push(tagToAdd)
this.tags.push(this.createTag(tagToAdd))
this.$emit('input', this.tags)
this.$emit('add', tagToAdd)
}
Expand Down

0 comments on commit c2a67ae

Please sign in to comment.