Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修改table中的mapping使用tag的时候展示不符合预期的bug #6395

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions packages/amis/src/renderers/Mapping.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,27 @@ export const MappingField = withStore(props =>
label = value[labelField || 'label'];
}
}
return render('tpl', label);
let realValue = value;
if (
isObject(label)
&& label.type === 'tag'
&& !isObject(label.label)
&& label.label != null
) {
realValue = label.label;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

label可以是变量

}
return render('tpl', label, {
data: createObject(data, {
value: realValue,
label: realValue
}),
value: null
});
}

return render('mappingItemSchema', itemSchema, {
data: createObject(data, isObject(value) ? value : {item: value})
data: createObject(data, isObject(value) ? value : {item: value}),
// 阻止 itemSchema 从props.value 取值,否则渲染不正确
value: null
});
}

Expand Down