Commit d4f39edc359c515dbf62b509a89b2070ffaf79c7
Committed by
GitHub
Merge pull request #3576 from SergioCrisostomo/refactor-select
Select related fixes
Showing
2 changed files
with
18 additions
and
16 deletions
Show diff stats
src/components/select/select.vue
... | ... | @@ -56,12 +56,12 @@ |
56 | 56 | > |
57 | 57 | <ul v-show="showNotFoundLabel" :class="[prefixCls + '-not-found']"><li>{{ localeNotFoundText }}</li></ul> |
58 | 58 | <ul :class="prefixCls + '-dropdown-list'"> |
59 | - <functional-options | |
60 | - v-if="(!remote) || (remote && !loading)" | |
61 | - :options="selectOptions" | |
62 | - :slot-update-hook="updateSlotOptions" | |
63 | - :slot-options="slotOptions" | |
64 | - ></functional-options> | |
59 | + <functional-options | |
60 | + v-if="(!remote) || (remote && !loading)" | |
61 | + :options="selectOptions" | |
62 | + :slot-update-hook="updateSlotOptions" | |
63 | + :slot-options="slotOptions" | |
64 | + ></functional-options> | |
65 | 65 | </ul> |
66 | 66 | <ul v-show="loading" :class="[prefixCls + '-loading']">{{ localeLoadingText }}</ul> |
67 | 67 | </Drop> |
... | ... | @@ -207,7 +207,7 @@ |
207 | 207 | |
208 | 208 | // set the initial values if there are any |
209 | 209 | if (this.values.length > 0 && !this.remote && this.selectOptions.length > 0){ |
210 | - this.values = this.values.map(this.getOptionData); | |
210 | + this.values = this.values.map(this.getOptionData).filter(Boolean); | |
211 | 211 | } |
212 | 212 | |
213 | 213 | if (this.values.length > 0 && this.selectOptions.length === 0){ |
... | ... | @@ -307,7 +307,7 @@ |
307 | 307 | const slotOptions = (this.slotOptions || []); |
308 | 308 | let optionCounter = -1; |
309 | 309 | const currentIndex = this.focusIndex; |
310 | - const selectedValues = this.values.map(({value}) => value); | |
310 | + const selectedValues = this.values.filter(Boolean).map(({value}) => value); | |
311 | 311 | if (this.autoComplete) { |
312 | 312 | const copyChildren = (node, fn) => { |
313 | 313 | return { |
... | ... | @@ -398,7 +398,7 @@ |
398 | 398 | const {multiple, value} = this; |
399 | 399 | let initialValue = Array.isArray(value) ? value : [value]; |
400 | 400 | if (!multiple && (typeof initialValue[0] === 'undefined' || String(initialValue[0]).trim() === '')) initialValue = []; |
401 | - return initialValue; | |
401 | + return initialValue.filter(Boolean); | |
402 | 402 | }, |
403 | 403 | processOption(option, values, isFocused){ |
404 | 404 | if (!option.componentOptions) return option; |
... | ... | @@ -482,6 +482,7 @@ |
482 | 482 | |
483 | 483 | // Esc slide-up |
484 | 484 | if (e.key === 'Escape') { |
485 | + e.stopPropagation(); | |
485 | 486 | this.hideMenu(); |
486 | 487 | } |
487 | 488 | // next |
... | ... | @@ -493,7 +494,8 @@ |
493 | 494 | this.navigateOptions(1); |
494 | 495 | } |
495 | 496 | // enter |
496 | - if (e.key === 'Enter' && this.focusIndex > -1) { | |
497 | + if (e.key === 'Enter') { | |
498 | + if (this.focusIndex === -1) return this.hideMenu(); | |
497 | 499 | const optionComponent = this.flatOptions[this.focusIndex]; |
498 | 500 | const option = this.getOptionData(optionComponent.componentOptions.propsData.value); |
499 | 501 | this.onOptionClick(option); |
... | ... | @@ -580,7 +582,7 @@ |
580 | 582 | |
581 | 583 | if (value === '') this.values = []; |
582 | 584 | else if (JSON.stringify(value) !== JSON.stringify(publicValue)) { |
583 | - this.$nextTick(() => this.values = getInitialValue().map(getOptionData)); | |
585 | + this.$nextTick(() => this.values = getInitialValue().map(getOptionData).filter(Boolean)); | |
584 | 586 | } |
585 | 587 | }, |
586 | 588 | values(now, before){ |
... | ... | @@ -592,8 +594,8 @@ |
592 | 594 | // v-model is always just the value, event with labelInValue === true |
593 | 595 | const vModelValue = this.labelInValue ? |
594 | 596 | (this.multiple ? this.publicValue.map(({value}) => value) |
595 | - : | |
596 | - this.publicValue.value) : this.publicValue; | |
597 | + : | |
598 | + this.publicValue.value) : this.publicValue; | |
597 | 599 | this.$emit('input', vModelValue); // to update v-model |
598 | 600 | this.$emit('on-change', this.publicValue); |
599 | 601 | this.dispatch('FormItem', 'on-form-change', this.publicValue); |
... | ... | @@ -659,7 +661,7 @@ |
659 | 661 | }, |
660 | 662 | selectOptions(){ |
661 | 663 | if (this.hasExpectedValue){ |
662 | - this.values = this.values.map(this.getOptionData); | |
664 | + this.values = this.values.map(this.getOptionData).filter(Boolean); | |
663 | 665 | this.hasExpectedValue = false; |
664 | 666 | } |
665 | 667 | ... | ... |
src/locale/lang/sv-SE.js
... | ... | @@ -6,7 +6,7 @@ const lang = { |
6 | 6 | select: { |
7 | 7 | placeholder: 'Välj', |
8 | 8 | noMatch: 'Ingen träff', |
9 | - loading: 'Ladar' | |
9 | + loading: 'Laddar' | |
10 | 10 | }, |
11 | 11 | table: { |
12 | 12 | noDataText: 'Ingen data', |
... | ... | @@ -102,4 +102,4 @@ const lang = { |
102 | 102 | |
103 | 103 | setLang(lang); |
104 | 104 | |
105 | -export default lang; | |
106 | 105 | \ No newline at end of file |
106 | +export default lang; | ... | ... |