Merge pull request #3576 from SergioCrisostomo/refactor-select
Select related fixes
This commit is contained in:
commit
d4f39edc35
2 changed files with 18 additions and 16 deletions
|
@ -56,12 +56,12 @@
|
|||
>
|
||||
<ul v-show="showNotFoundLabel" :class="[prefixCls + '-not-found']"><li>{{ localeNotFoundText }}</li></ul>
|
||||
<ul :class="prefixCls + '-dropdown-list'">
|
||||
<functional-options
|
||||
v-if="(!remote) || (remote && !loading)"
|
||||
:options="selectOptions"
|
||||
:slot-update-hook="updateSlotOptions"
|
||||
:slot-options="slotOptions"
|
||||
></functional-options>
|
||||
<functional-options
|
||||
v-if="(!remote) || (remote && !loading)"
|
||||
:options="selectOptions"
|
||||
:slot-update-hook="updateSlotOptions"
|
||||
:slot-options="slotOptions"
|
||||
></functional-options>
|
||||
</ul>
|
||||
<ul v-show="loading" :class="[prefixCls + '-loading']">{{ localeLoadingText }}</ul>
|
||||
</Drop>
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
export default lang;
|
||||
|
|
Loading…
Add table
Reference in a new issue