From 0fb9d6453a317e5a8a7d589b3073f75df1541463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=95=8F?= Date: Sun, 3 Jun 2018 23:18:29 +0800 Subject: [PATCH 1/8] fix bug #3795 --- src/components/select/select.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index ad2fc02f..feaff4dd 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -230,8 +230,8 @@ }).filter(Boolean); } - if (this.values.length > 0 && this.selectOptions.length === 0){ - this.hasExpectedValue = this.values; + if (this.getInitialValue().length > 0 && this.selectOptions.length === 0){ + this.hasExpectedValue = true; } }, data () { @@ -716,7 +716,10 @@ this.broadcast('Drop', open ? 'on-update-popper' : 'on-destroy-popper'); }, selectOptions(){ - if (this.hasExpectedValue){ + if (this.hasExpectedValue && this.selectOptions.length > 0){ + if (this.values.length === 0) { + this.values = this.getInitialValue(); + } this.values = this.values.map(this.getOptionData).filter(Boolean); this.hasExpectedValue = false; } From 9ccd81961bc8759601d3b63a916c1ab31ff34e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=95=8F?= Date: Tue, 5 Jun 2018 14:00:16 +0800 Subject: [PATCH 2/8] fixed #3722 --- src/components/select/select.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index feaff4dd..f1e42664 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -638,6 +638,10 @@ value(value){ const {getInitialValue, getOptionData, publicValue} = this; + if (getInitialValue().length > 0) { + this.hasExpectedValue = true + } + if (value === '') this.values = []; else if (JSON.stringify(value) !== JSON.stringify(publicValue)) { this.$nextTick(() => this.values = getInitialValue().map(getOptionData).filter(Boolean)); From 73b01ee06bcd37925e0379ba5a602b94abcbfbcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=95=8F?= Date: Tue, 5 Jun 2018 14:32:19 +0800 Subject: [PATCH 3/8] fixed #3722 that check expected value status --- src/components/select/select.vue | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index f1e42664..d426c545 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -230,9 +230,7 @@ }).filter(Boolean); } - if (this.getInitialValue().length > 0 && this.selectOptions.length === 0){ - this.hasExpectedValue = true; - } + this.checkUpdateStatus(); }, data () { @@ -632,15 +630,18 @@ }, updateSlotOptions(){ this.slotOptions = this.$slots.default; + }, + checkUpdateStatus() { + if (this.getInitialValue().length > 0 && this.selectOptions.length === 0) { + this.hasExpectedValue = true; + } } }, watch: { value(value){ const {getInitialValue, getOptionData, publicValue} = this; - if (getInitialValue().length > 0) { - this.hasExpectedValue = true - } + this.checkUpdateStatus(); if (value === '') this.values = []; else if (JSON.stringify(value) !== JSON.stringify(publicValue)) { From 21f6940672e1c692b0f612214233e0f882b940fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=95=8F?= Date: Thu, 7 Jun 2018 09:58:13 +0800 Subject: [PATCH 4/8] fixed #3817 #3836 --- src/components/select/select-head.vue | 2 +- src/components/select/select.vue | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/select/select-head.vue b/src/components/select/select-head.vue index 4165e5f5..10004b8d 100644 --- a/src/components/select/select-head.vue +++ b/src/components/select/select-head.vue @@ -58,7 +58,7 @@ default: false }, initialLabel: { - type: String, + type: [String, Number, Array], }, values: { type: Array, diff --git a/src/components/select/select.vue b/src/components/select/select.vue index d426c545..8e177c06 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -351,7 +351,7 @@ }); }); } - + let hasDefaultSelected = slotOptions.some(option => this.query === option.key); for (let option of slotOptions) { const cOptions = option.componentOptions; @@ -375,11 +375,13 @@ if (cOptions.children.length > 0) selectOptions.push({...option}); } else { // ignore option if not passing filter - const optionPassesFilter = this.filterable ? this.validateOption(cOptions) : option; - if (!optionPassesFilter) continue; + if (!hasDefaultSelected) { + const optionPassesFilter = this.filterable ? this.validateOption(cOptions) : option; + if (!optionPassesFilter) continue; + } optionCounter = optionCounter + 1; - selectOptions.push(this.processOption(option, selectedValues, optionCounter === currentIndex)); + selectOptions.push(this.processOption(option, selectedValues, false)); } } From fdc71ffe95361bbe7c4a12bcdb214f9b7fd268fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=95=8F?= Date: Thu, 7 Jun 2018 10:07:34 +0800 Subject: [PATCH 5/8] reset the focus index setting. --- src/components/select/select.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index 8e177c06..4f89f0d3 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -381,7 +381,7 @@ } optionCounter = optionCounter + 1; - selectOptions.push(this.processOption(option, selectedValues, false)); + selectOptions.push(this.processOption(option, selectedValues, optionCounter === currentIndex)); } } From 78824cc259637dbc51a12d111652d440f9510ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=95=8F?= Date: Thu, 7 Jun 2018 14:06:30 +0800 Subject: [PATCH 6/8] fixed #3817 that the default value does't display bug. --- 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 4f89f0d3..ceca5274 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -351,7 +351,7 @@ }); }); } - let hasDefaultSelected = slotOptions.some(option => this.query === option.key); + let hasDefaultSelected = slotOptions.some(option => this.query === option.componentOptions.propsData.value); for (let option of slotOptions) { const cOptions = option.componentOptions; @@ -426,6 +426,7 @@ const {multiple, value} = this; let initialValue = Array.isArray(value) ? value : [value]; if (!multiple && (typeof initialValue[0] === 'undefined' || (String(initialValue[0]).trim() === '' && !Number.isFinite(initialValue[0])))) initialValue = []; + if (this.remote && this.value) this.query = value; return initialValue.filter((item) => { return Boolean(item) || item === 0; }); From 4403f97d4484dacc0f298731d521d61cf8558e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=95=8F?= Date: Thu, 7 Jun 2018 14:57:22 +0800 Subject: [PATCH 7/8] fixed when selector is multiple mode error. --- src/components/select/select.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index ceca5274..228c23ad 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -351,7 +351,7 @@ }); }); } - let hasDefaultSelected = slotOptions.some(option => this.query === option.componentOptions.propsData.value); + let hasDefaultSelected = slotOptions.some(option => this.query === option.key); for (let option of slotOptions) { const cOptions = option.componentOptions; @@ -426,7 +426,7 @@ const {multiple, value} = this; let initialValue = Array.isArray(value) ? value : [value]; if (!multiple && (typeof initialValue[0] === 'undefined' || (String(initialValue[0]).trim() === '' && !Number.isFinite(initialValue[0])))) initialValue = []; - if (this.remote && this.value) this.query = value; + if (this.remote && this.value) this.query = Array.isArray(value) ? "" : value; return initialValue.filter((item) => { return Boolean(item) || item === 0; }); From 1d680640f76628612c501a2af81de49ab9dc3916 Mon Sep 17 00:00:00 2001 From: m430 <360475097@qq.com> Date: Thu, 7 Jun 2018 15:17:06 +0800 Subject: [PATCH 8/8] fixed the multiple cannot be force set the query value. --- src/components/select/select.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index 228c23ad..d09dd7e4 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -426,7 +426,7 @@ const {multiple, value} = this; let initialValue = Array.isArray(value) ? value : [value]; if (!multiple && (typeof initialValue[0] === 'undefined' || (String(initialValue[0]).trim() === '' && !Number.isFinite(initialValue[0])))) initialValue = []; - if (this.remote && this.value) this.query = Array.isArray(value) ? "" : value; + if (this.remote && !this.multiple && this.value) this.query = value; return initialValue.filter((item) => { return Boolean(item) || item === 0; });