fix: variable parsing incompatibility with {{title}} data in secondary confirm (#6838)

* fix: variable parsing incompatibility with {{title}} data in secondary confirmation

* fix: bug
This commit is contained in:
Katherine 2025-05-08 20:41:14 +08:00 committed by GitHub
parent 18f7dc6d17
commit 25bfdd61d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -739,9 +739,11 @@ export function SecondConFirm() {
title={t('Secondary confirmation')}
initialValues={{
title:
t(fieldSchema?.['x-component-props']?.confirm?.title, { title: compile(fieldSchema.title) }) ||
compile(fieldSchema?.['x-component-props']?.confirm?.title) ||
t('Perform the {{title}}', { title: compile(fieldSchema.title) }),
content:
t(fieldSchema?.['x-component-props']?.confirm?.content, { title: compile(fieldSchema.title) }) ||
compile(fieldSchema?.['x-component-props']?.confirm?.content) ||
t('Are you sure you want to perform the {{title}} action?', { title: compile(fieldSchema.title) }),
}}

View File

@ -454,6 +454,7 @@ const RenderButton = ({
const variables = useVariables();
const localVariables = useLocalVariables();
const openPopupRef = useRef(null);
const compile = useCompile();
openPopupRef.current = openPopup;
const scopes = {
variables,
@ -467,8 +468,9 @@ const RenderButton = ({
}
e.preventDefault();
e.stopPropagation();
const resultTitle = await getVariableValue(confirm?.title, scopes);
const resultContent = await getVariableValue(confirm?.content, scopes);
const resultTitle = await getVariableValue(t(confirm?.title, { title: compile(fieldSchema.title) }), scopes);
const resultContent = await getVariableValue(t(confirm?.content, { title: compile(fieldSchema.title) }), scopes);
if (!disabled && aclCtx) {
const onOk = () => {
if (onClick) {