From 72e9533b7d452a2de2cff1e72621a7997696f4e8 Mon Sep 17 00:00:00 2001 From: anuoua Date: Thu, 5 Jan 2023 12:45:06 +0800 Subject: [PATCH] fix: snapshot display fix (#1328) --- .../record-picker/ReadPrettyRecordPicker.tsx | 27 ++++++++++--------- .../antd/select/ReadPretty.tsx | 5 +++- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/record-picker/ReadPrettyRecordPicker.tsx b/packages/core/client/src/schema-component/antd/record-picker/ReadPrettyRecordPicker.tsx index b1972cd3d..3b37efddb 100644 --- a/packages/core/client/src/schema-component/antd/record-picker/ReadPrettyRecordPicker.tsx +++ b/packages/core/client/src/schema-component/antd/record-picker/ReadPrettyRecordPicker.tsx @@ -47,18 +47,21 @@ export const ReadPrettyRecordPicker: React.FC = observer((props: any) => { return ( - { - if (snapshot) return; - e.stopPropagation(); - e.preventDefault(); - setVisible(true); - setRecord(record); - ellipsisWithTooltipRef?.current?.setPopoverVisible(false); - }} - > - {getLabelFormatValue(labelUiSchema, val)} - + {snapshot ? ( + getLabelFormatValue(labelUiSchema, val) + ) : ( + { + e.stopPropagation(); + e.preventDefault(); + setVisible(true); + setRecord(record); + ellipsisWithTooltipRef?.current?.setPopoverVisible(false); + }} + > + {getLabelFormatValue(labelUiSchema, val)} + + )} {index < arr.length - 1 ? , : null} diff --git a/packages/core/client/src/schema-component/antd/select/ReadPretty.tsx b/packages/core/client/src/schema-component/antd/select/ReadPretty.tsx index 95fb7ac51..150a02724 100644 --- a/packages/core/client/src/schema-component/antd/select/ReadPretty.tsx +++ b/packages/core/client/src/schema-component/antd/select/ReadPretty.tsx @@ -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(); + const compile = useCompile(); + if (!isValid(props.value)) { return
; } @@ -25,7 +28,7 @@ export const ReadPretty = observer((props: any) => {
{options.map((option, key) => ( - {option[fieldNames.label]} + {compile(option[fieldNames.label])} ))}