fix: resolve map rendering in sub-details and incorrect value display for empty fields (#5526)

* fix: bug

* fix: test
This commit is contained in:
Katherine 2024-10-29 17:02:22 +08:00 committed by GitHub
parent eb5e23f686
commit 67e1373077
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 7 additions and 8 deletions

View File

@ -2,9 +2,7 @@
"version": "1.3.42-beta", "version": "1.3.42-beta",
"npmClient": "yarn", "npmClient": "yarn",
"useWorkspaces": true, "useWorkspaces": true,
"npmClientArgs": [ "npmClientArgs": ["--ignore-engines"],
"--ignore-engines"
],
"command": { "command": {
"version": { "version": {
"forcePublish": true, "forcePublish": true,

View File

@ -142,6 +142,8 @@ export const useDetailsBlockProps = () => {
.reset() .reset()
.then(() => { .then(() => {
ctx.form.setInitialValues(data || {}); ctx.form.setInitialValues(data || {});
ctx.form.setValues(data || {});
// Using `ctx.form.setValues(data || {});` here may cause an internal infinite loop in Formily // Using `ctx.form.setValues(data || {});` here may cause an internal infinite loop in Formily
}) })
.catch(console.error); .catch(console.error);

View File

@ -159,7 +159,7 @@ test.describe('form item & edit form', () => {
gotoPage: async () => { gotoPage: async () => {
record = await (async (mockPage, mockRecord) => { record = await (async (mockPage, mockRecord) => {
const nocoPage = await mockPage(oneTableBlockWithAddNewAndViewAndEditAndChoicesFields).waitForInit(); const nocoPage = await mockPage(oneTableBlockWithAddNewAndViewAndEditAndChoicesFields).waitForInit();
const record = await mockRecord('general'); const record = await mockRecord('general', { checkbox: false });
await nocoPage.goto(); await nocoPage.goto();
return record; return record;

View File

@ -27,7 +27,6 @@ export const MapComponent = React.forwardRef<any, any>((props, ref) => {
if (!Component) { if (!Component) {
return <div>{t(`The ${mapType} cannot found`)}</div>; return <div>{t(`The ${mapType} cannot found`)}</div>;
} }
return <Component ref={ref} {...props} />; return <Component ref={ref} {...props} />;
}); });
MapComponent.displayName = 'MapComponent'; MapComponent.displayName = 'MapComponent';

View File

@ -7,7 +7,7 @@
* For more information, please refer to: https://www.nocobase.com/agreement. * For more information, please refer to: https://www.nocobase.com/agreement.
*/ */
import { useFieldSchema, useForm } from '@formily/react'; import { useField, useFieldSchema, useForm } from '@formily/react';
import { EllipsisWithTooltip, useCollection_deprecated, useFieldTitle } from '@nocobase/client'; import { EllipsisWithTooltip, useCollection_deprecated, useFieldTitle } from '@nocobase/client';
import React from 'react'; import React from 'react';
import { MapComponent } from './MapComponent'; import { MapComponent } from './MapComponent';
@ -19,9 +19,9 @@ const ReadPretty = (props) => {
const collectionField = getField(fieldSchema.name); const collectionField = getField(fieldSchema.name);
const mapType = props.mapType || collectionField?.uiSchema['x-component-props']?.mapType; const mapType = props.mapType || collectionField?.uiSchema['x-component-props']?.mapType;
const form = useForm(); const form = useForm();
const field = useField();
useFieldTitle(); useFieldTitle();
if (!form.readPretty || field.readPretty) {
if (!form.readPretty) {
return ( return (
<div> <div>
<EllipsisWithTooltip ellipsis={true}> <EllipsisWithTooltip ellipsis={true}>