mirror of
https://github.com/twentyhq/twenty.git
synced 2024-11-23 14:03:35 +03:00
[fix] Do not stringify json field value if null (#5348)
as per title https://github.com/twentyhq/twenty/assets/51697796/74ff0185-f20c-4ff1-9d89-3078063f23e1
This commit is contained in:
parent
8590bd7227
commit
999a66882d
@ -1,13 +1,18 @@
|
||||
import { useJsonField } from '@/object-record/record-field/meta-types/hooks/useJsonField';
|
||||
import { isFieldRawJsonValue } from '@/object-record/record-field/types/guards/isFieldRawJsonValue';
|
||||
import { JsonDisplay } from '@/ui/field/display/components/JsonDisplay';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
export const JsonFieldDisplay = () => {
|
||||
const { fieldValue, maxWidth } = useJsonField();
|
||||
|
||||
return (
|
||||
<JsonDisplay
|
||||
text={isFieldRawJsonValue(fieldValue) ? JSON.stringify(fieldValue) : ''}
|
||||
text={
|
||||
isFieldRawJsonValue(fieldValue) && isDefined(fieldValue)
|
||||
? JSON.stringify(fieldValue)
|
||||
: ''
|
||||
}
|
||||
maxWidth={maxWidth}
|
||||
/>
|
||||
);
|
||||
|
@ -8,6 +8,7 @@ import { isFieldRawJsonValue } from '@/object-record/record-field/types/guards/i
|
||||
import { isFieldRelation } from '@/object-record/record-field/types/guards/isFieldRelation';
|
||||
import { computeEmptyDraftValue } from '@/object-record/record-field/utils/computeEmptyDraftValue';
|
||||
import { isFieldValueEmpty } from '@/object-record/record-field/utils/isFieldValueEmpty';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
type computeDraftValueFromFieldValueParams<FieldValue> = {
|
||||
fieldDefinition: Pick<FieldDefinition<FieldMetadata>, 'type'>;
|
||||
@ -41,7 +42,7 @@ export const computeDraftValueFromFieldValue = <FieldValue>({
|
||||
}
|
||||
|
||||
if (isFieldRawJson(fieldDefinition)) {
|
||||
return isFieldRawJsonValue(fieldValue)
|
||||
return isFieldRawJsonValue(fieldValue) && isDefined(fieldValue)
|
||||
? (JSON.stringify(
|
||||
fieldValue,
|
||||
null,
|
||||
|
Loading…
Reference in New Issue
Block a user