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",
"npmClient": "yarn",
"useWorkspaces": true,
"npmClientArgs": [
"--ignore-engines"
],
"npmClientArgs": ["--ignore-engines"],
"command": {
"version": {
"forcePublish": true,

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@
* 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 React from 'react';
import { MapComponent } from './MapComponent';
@ -19,9 +19,9 @@ const ReadPretty = (props) => {
const collectionField = getField(fieldSchema.name);
const mapType = props.mapType || collectionField?.uiSchema['x-component-props']?.mapType;
const form = useForm();
const field = useField();
useFieldTitle();
if (!form.readPretty) {
if (!form.readPretty || field.readPretty) {
return (
<div>
<EllipsisWithTooltip ellipsis={true}>