diff --git a/src/components/select/select.vue b/src/components/select/select.vue index dbe2fa8f..6ca51b3d 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -56,12 +56,12 @@ > @@ -207,7 +207,7 @@ // set the initial values if there are any if (this.values.length > 0 && !this.remote && this.selectOptions.length > 0){ - this.values = this.values.map(this.getOptionData); + this.values = this.values.map(this.getOptionData).filter(Boolean); } if (this.values.length > 0 && this.selectOptions.length === 0){ @@ -307,7 +307,7 @@ const slotOptions = (this.slotOptions || []); let optionCounter = -1; const currentIndex = this.focusIndex; - const selectedValues = this.values.map(({value}) => value); + const selectedValues = this.values.filter(Boolean).map(({value}) => value); if (this.autoComplete) { const copyChildren = (node, fn) => { return { @@ -398,7 +398,7 @@ const {multiple, value} = this; let initialValue = Array.isArray(value) ? value : [value]; if (!multiple && (typeof initialValue[0] === 'undefined' || String(initialValue[0]).trim() === '')) initialValue = []; - return initialValue; + return initialValue.filter(Boolean); }, processOption(option, values, isFocused){ if (!option.componentOptions) return option; @@ -482,6 +482,7 @@ // Esc slide-up if (e.key === 'Escape') { + e.stopPropagation(); this.hideMenu(); } // next @@ -493,7 +494,8 @@ this.navigateOptions(1); } // enter - if (e.key === 'Enter' && this.focusIndex > -1) { + if (e.key === 'Enter') { + if (this.focusIndex === -1) return this.hideMenu(); const optionComponent = this.flatOptions[this.focusIndex]; const option = this.getOptionData(optionComponent.componentOptions.propsData.value); this.onOptionClick(option); @@ -580,7 +582,7 @@ if (value === '') this.values = []; else if (JSON.stringify(value) !== JSON.stringify(publicValue)) { - this.$nextTick(() => this.values = getInitialValue().map(getOptionData)); + this.$nextTick(() => this.values = getInitialValue().map(getOptionData).filter(Boolean)); } }, values(now, before){ @@ -592,8 +594,8 @@ // v-model is always just the value, event with labelInValue === true const vModelValue = this.labelInValue ? (this.multiple ? this.publicValue.map(({value}) => value) - : - this.publicValue.value) : this.publicValue; + : + this.publicValue.value) : this.publicValue; this.$emit('input', vModelValue); // to update v-model this.$emit('on-change', this.publicValue); this.dispatch('FormItem', 'on-form-change', this.publicValue); @@ -659,7 +661,7 @@ }, selectOptions(){ if (this.hasExpectedValue){ - this.values = this.values.map(this.getOptionData); + this.values = this.values.map(this.getOptionData).filter(Boolean); this.hasExpectedValue = false; } diff --git a/src/locale/lang/sv-SE.js b/src/locale/lang/sv-SE.js index c9beb861..13610659 100644 --- a/src/locale/lang/sv-SE.js +++ b/src/locale/lang/sv-SE.js @@ -6,7 +6,7 @@ const lang = { select: { placeholder: 'Välj', noMatch: 'Ingen träff', - loading: 'Ladar' + loading: 'Laddar' }, table: { noDataText: 'Ingen data', @@ -102,4 +102,4 @@ const lang = { setLang(lang); -export default lang; \ No newline at end of file +export default lang;