From 59865248f0dc632d0f78fb695bd09dcf4f965fbf Mon Sep 17 00:00:00 2001 From: Junyi Date: Tue, 11 Apr 2023 10:14:37 +0700 Subject: [PATCH] fix(client): fix constant input lose focus in variable (#1689) --- .../src/schema-component/antd/variable/Input.tsx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/variable/Input.tsx b/packages/core/client/src/schema-component/antd/variable/Input.tsx index 0ddb474d8..59e54925a 100644 --- a/packages/core/client/src/schema-component/antd/variable/Input.tsx +++ b/packages/core/client/src/schema-component/antd/variable/Input.tsx @@ -98,14 +98,14 @@ const ConstantTypes = { -function getTypedConstantOption(type) { +function getTypedConstantOption(type, props) { const { t } = useTranslation(); return { value: '', label: t('Constant'), children: Object.values(ConstantTypes), - component: ConstantTypes[type]?.component + content: ConstantTypes[type]?.component({ value: props.value, onChange: props.onChange }) }; } @@ -122,18 +122,18 @@ export function Input(props) { const type = isConstant ? parsed : ''; const variable = isConstant ? null : parsed; const compile = useCompile(); - const { component: ConstantComponent, ...constantOption }: VariableOptions & { component: React.FC } = children + const { content, ...constantOption }: VariableOptions & { content: React.ReactNode } = children ? { value: '', label: '{{t("Constant")}}', - component: () => children + content: children } : (useTypedConstant - ? getTypedConstantOption(type) + ? getTypedConstantOption(type, props) : { value: '', label: '{{t("Null")}}', - component: ConstantTypes.null.component + content: ConstantTypes.null.component() } ); const options: VariableOptions[] = compile([ @@ -247,9 +247,7 @@ export function Input(props) { ) : null} - ) : ( - - )} + ) : content} {options.length > 1 ? (