fix: snapshot display fix (#1328)

This commit is contained in:
anuoua 2023-01-05 12:45:06 +08:00 committed by GitHub
parent c851e65459
commit 72e9533b7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 13 deletions

View File

@ -47,18 +47,21 @@ export const ReadPrettyRecordPicker: React.FC = observer((props: any) => {
return (
<Fragment key={`${record.id}_${index}`}>
<span>
<a
onClick={(e) => {
if (snapshot) return;
e.stopPropagation();
e.preventDefault();
setVisible(true);
setRecord(record);
ellipsisWithTooltipRef?.current?.setPopoverVisible(false);
}}
>
{getLabelFormatValue(labelUiSchema, val)}
</a>
{snapshot ? (
getLabelFormatValue(labelUiSchema, val)
) : (
<a
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
setVisible(true);
setRecord(record);
ellipsisWithTooltipRef?.current?.setPopoverVisible(false);
}}
>
{getLabelFormatValue(labelUiSchema, val)}
</a>
)}
</span>
{index < arr.length - 1 ? <span style={{ marginRight: 4, color: '#aaa' }}>,</span> : null}
</Fragment>

View File

@ -3,6 +3,7 @@ import { observer, useField } from '@formily/react';
import { isValid } from '@formily/shared';
import { Tag } from 'antd';
import React from 'react';
import { useCompile } from '../../hooks';
import { defaultFieldNames, getCurrentOptions } from './shared';
type Composed = {
@ -13,6 +14,8 @@ type Composed = {
export const ReadPretty = observer((props: any) => {
const fieldNames = { ...defaultFieldNames, ...props.fieldNames };
const field = useField<any>();
const compile = useCompile();
if (!isValid(props.value)) {
return <div />;
}
@ -25,7 +28,7 @@ export const ReadPretty = observer((props: any) => {
<div>
{options.map((option, key) => (
<Tag key={key} color={option[fieldNames.color]} icon={option.icon}>
{option[fieldNames.label]}
{compile(option[fieldNames.label])}
</Tag>
))}
</div>