fix(tag): reset closable default value to false

This commit is contained in:
07akioni 2020-04-23 18:09:57 +08:00
parent 72d5d34feb
commit 9dd2c5fc49
3 changed files with 38 additions and 11 deletions

View File

@ -18,11 +18,12 @@
v-if="inputVisible" v-if="inputVisible"
ref="tagInput" ref="tagInput"
v-model="inputValue" v-model="inputValue"
:force-focus="inputForceFocused"
:theme="theme" :theme="theme"
:style="inputStyle" :style="inputStyle"
:size="inputSize" :size="inputSize"
@keyup.enter.native="handleInputConfirm" @keyup.enter.native="handleInputConfirm"
@blur="handleInputConfirm" @blur="handleInputBlur"
/> />
<n-button <n-button
v-else v-else
@ -30,7 +31,11 @@
:size="inputSize" :size="inputSize"
@click="handleAddClick" @click="handleAddClick"
> >
+ {{ localizedAdd }} <template v-slot:icon>
<n-icon>
<add-outline />
</n-icon>
</template>
</n-button> </n-button>
</div> </div>
</template> </template>
@ -42,21 +47,34 @@ import asformitem from '../../_mixins/asformitem'
import locale from '../../_mixins/locale' import locale from '../../_mixins/locale'
import NTag from './main' import NTag from './main'
import commonProps from './commonProps' import commonProps from './commonProps'
import NIcon from '../../Icon'
import addOutline from '../../_icons/add-outline'
export default { export default {
name: 'NDynamicTags', name: 'NDynamicTags',
components: { components: {
NTag NTag,
NIcon,
addOutline
}, },
mixins: [withapp, themeable, locale('Tag'), asformitem({ mixins: [
change: 'change' withapp,
})], themeable,
locale('Tag'),
asformitem({
change: 'change'
})
],
model: { model: {
name: 'value', name: 'value',
event: 'change' event: 'change'
}, },
props: { props: {
...commonProps, ...commonProps,
closable: {
type: Boolean,
default: true
},
value: { value: {
type: Array, type: Array,
default: () => { default: () => {
@ -67,8 +85,7 @@ export default {
type: Object, type: Object,
default: () => { default: () => {
return { return {
marginRight: '5px', marginRight: '6px'
marginBottom: '5px'
} }
} }
}, },
@ -76,7 +93,7 @@ export default {
type: Object, type: Object,
default: () => { default: () => {
return { return {
width: '50px' width: '64px'
} }
} }
} }
@ -84,7 +101,8 @@ export default {
data () { data () {
return { return {
inputValue: '', inputValue: '',
inputVisible: false inputVisible: false,
inputForceFocused: true
} }
}, },
computed: { computed: {
@ -111,12 +129,17 @@ export default {
this.$emit('change', tags) this.$emit('change', tags)
} }
this.inputVisible = false this.inputVisible = false
this.inputForceFocused = true
this.inputValue = '' this.inputValue = ''
}, },
handleInputBlur () {
this.handleInputConfirm()
},
handleAddClick () { handleAddClick () {
this.inputVisible = true this.inputVisible = true
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.tagInput.focus() this.$refs.tagInput.focus()
this.inputForceFocused = false
}) })
} }
} }

View File

@ -17,7 +17,7 @@ export default {
}, },
closable: { closable: {
type: Boolean, type: Boolean,
default: true default: false
}, },
disabled: { disabled: {
type: Boolean, type: Boolean,

View File

@ -144,4 +144,8 @@
} }
} }
} }
}
@include b(dynamic-tags) {
display: inline-flex;
} }