From d4972560057fee09d349775d2ff659713c9a9b39 Mon Sep 17 00:00:00 2001 From: liaoxuezhi Date: Tue, 3 Dec 2019 20:02:01 +0800 Subject: [PATCH] =?UTF-8?q?Select=20autoComplet=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=20sendOn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderers/Form/Select.tsx | 42 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/renderers/Form/Select.tsx b/src/renderers/Form/Select.tsx index 35e449a76..010aaa63f 100644 --- a/src/renderers/Form/Select.tsx +++ b/src/renderers/Form/Select.tsx @@ -141,31 +141,29 @@ export default class SelectControl extends React.Component { options: combinedOptions }); } + const ctx = createObject(data, { + term: input, + value: input + }); + + if (!isEffectiveApi(autoComplete, ctx)) { + return; + } setLoading(true); - return ( - isEffectiveApi(autoComplete, data) && - env - .fetcher( - autoComplete, - createObject(data, { - term: input, - value: input - }) - ) - .then(ret => { - let options = - (ret.data && (ret.data as any).options) || ret.data || []; - this.cache[input] = options; - let combinedOptions = this.mergeOptions(options); - setOptions(combinedOptions); + return env + .fetcher(autoComplete, ctx) + .then(ret => { + let options = (ret.data && (ret.data as any).options) || ret.data || []; + this.cache[input] = options; + let combinedOptions = this.mergeOptions(options); + setOptions(combinedOptions); - return Promise.resolve({ - options: combinedOptions - }); - }) - .finally(() => setLoading(false)) - ); + return Promise.resolve({ + options: combinedOptions + }); + }) + .finally(() => setLoading(false)); } mergeOptions(options: Array) {