fix(Sub-details): the initializer button is not displayed when the field value is empty (#4019)

* test: add e2e

* fix: remove return
This commit is contained in:
Zeke Zhang 2024-04-11 23:02:04 +08:00 committed by GitHub
parent 0f0ccfa9da
commit beab81818f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 32 additions and 6 deletions

View File

@ -1,10 +1,10 @@
import { Field } from '@formily/core';
import { observer, useField, useFieldSchema } from '@formily/react';
import React, { useEffect, useMemo, useState } from 'react';
import { AssociationFieldContext } from './context';
import { markRecordAsNew } from '../../../data-source/collection-record/isNewRecord';
import { useCollection, useCollectionManager } from '../../../data-source/collection';
import { markRecordAsNew } from '../../../data-source/collection-record/isNewRecord';
import { useSchemaComponentContext } from '../../hooks';
import { AssociationFieldContext } from './context';
export const AssociationFieldProvider = observer(
(props) => {
@ -40,10 +40,6 @@ export const AssociationFieldProvider = observer(
const [loading, setLoading] = useState(!field.readPretty);
useEffect(() => {
if (field.readPretty) {
return;
}
setLoading(true);
if (!collectionField) {
setLoading(false);

View File

@ -670,6 +670,16 @@ test.describe('form item & view form', () => {
await expect(page.getByRole('option', { name: 'Tag', exact: true })).toBeVisible();
await expect(page.getByRole('option', { name: 'Sub-details', exact: true })).toBeVisible();
await expect(page.getByRole('option', { name: 'Sub-table', exact: true })).toBeVisible();
// 切换到 Sub-details应该显示 Initializer 按钮
await page.getByRole('option', { name: 'Sub-details', exact: true }).click();
await page.mouse.move(300, 0);
await expect(
page
.getByLabel('block-item-CollectionField-general-form-general.manyToMany-manyToMany')
.getByLabel('schema-initializer-Grid-form:')
.first(),
).toBeVisible();
});
test('title field', async ({ page, mockPage, mockRecords }) => {

View File

@ -509,6 +509,16 @@ test.describe('form item & view form', () => {
await expect(page.getByRole('option', { name: 'Title', exact: true })).toBeVisible();
await expect(page.getByRole('option', { name: 'Tag', exact: true })).toBeVisible();
await expect(page.getByRole('option', { name: 'Sub-details', exact: true })).toBeVisible();
// 切换到 Sub-details
await page.getByRole('option', { name: 'Sub-details' }).click();
await page.mouse.move(300, 0);
// 需要显示 Initializer 按钮
await expect(
page
.getByLabel('block-item-CollectionField-general-form-general.manyToOne-manyToOne')
.getByLabel('schema-initializer-Grid-form:'),
).toBeVisible();
});
test('title field', async ({ page, mockPage, mockRecords }) => {

View File

@ -513,6 +513,16 @@ test.describe('form item & view form', () => {
await expect(page.getByRole('option', { name: 'Tag', exact: true })).toBeVisible();
await expect(page.getByRole('option', { name: 'Sub-table', exact: true })).toBeVisible();
await expect(page.getByRole('option', { name: 'Sub-details', exact: true })).toBeVisible();
// 切换到 Sub-details应该显示 Initializer 按钮
await page.getByRole('option', { name: 'Sub-details', exact: true }).click();
await page.mouse.move(300, 0);
await expect(
page
.getByLabel('block-item-CollectionField-general-form-general.oneToMany-oneToMany')
.getByLabel('schema-initializer-Grid-form:')
.first(),
).toBeVisible();
});
test('title field', async ({ page, mockPage, mockRecords }) => {