From 220161f5edb25fea9098e65f5a1e7df12f63078f Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Tue, 8 May 2018 11:15:49 +0200 Subject: [PATCH 1/4] Clean up empty/null entries --- src/components/select/select.vue | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index dbe2fa8f..b4aa8d4e 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; @@ -580,7 +580,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 +592,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 +659,7 @@ }, selectOptions(){ if (this.hasExpectedValue){ - this.values = this.values.map(this.getOptionData); + this.values = this.values.map(this.getOptionData).filter(Boolean); this.hasExpectedValue = false; } From cca3bcaa1a2088ae00f18ba8cd508bf3228f6683 Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Tue, 8 May 2018 11:15:55 +0200 Subject: [PATCH 2/4] Fix typos --- src/locale/lang/sv-SE.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; From 16fc63614f25008e1b60a6442c04b252491be41f Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Tue, 8 May 2018 11:34:15 +0200 Subject: [PATCH 3/4] stop propagation on ESC key --- src/components/select/select.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index b4aa8d4e..013c1a53 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -482,6 +482,7 @@ // Esc slide-up if (e.key === 'Escape') { + e.stopPropagation(); this.hideMenu(); } // next From 7e3fc4a522c4629b5350b36e888a2304c23d8074 Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Tue, 8 May 2018 11:38:04 +0200 Subject: [PATCH 4/4] close the menu if no option is focused on Enter --- src/components/select/select.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index 013c1a53..6ca51b3d 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -494,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);