From 4fcf7e381521014ea4ea1399034282c0b4570691 Mon Sep 17 00:00:00 2001 From: Zeke Zhang <958414905@qq.com> Date: Thu, 24 Oct 2024 11:46:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(FilterBlocks):=20allow=20adding=20filter=20?= =?UTF-8?q?blocks=20in=20popup=20even=20without=20a=E2=80=A6=20(#5502)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(FilterBlocks): allow adding filter blocks in popup even without association fields * chore: make e2e more stable --- .../__e2e__/component/Input.Preview/basic.test.ts | 7 ++++++- .../buttons/RecordBlockInitializers.tsx | 12 +----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/packages/core/client/src/modules/fields/__e2e__/component/Input.Preview/basic.test.ts b/packages/core/client/src/modules/fields/__e2e__/component/Input.Preview/basic.test.ts index efa3dce47c..e893f2d0f5 100644 --- a/packages/core/client/src/modules/fields/__e2e__/component/Input.Preview/basic.test.ts +++ b/packages/core/client/src/modules/fields/__e2e__/component/Input.Preview/basic.test.ts @@ -32,7 +32,12 @@ test.describe('Input.Preview', () => { // 4. 切换图片大小到 Large,大小切换正常 await page.getByLabel('block-item-CollectionField-').hover(); await page.getByLabel('designer-schema-settings-CollectionField-fieldSettings:FormItem-general-general').hover(); - await page.getByRole('menuitem', { name: 'Size Small' }).click(); + await page.getByRole('menuitem', { name: 'Size Small' }).click({ + position: { + x: 160, + y: 10, + }, + }); await page.getByRole('option', { name: 'Large' }).click(); await expect(page.getByLabel('block-item-CollectionField-').getByRole('img').first()).toHaveJSProperty('width', 72); diff --git a/packages/core/client/src/schema-initializer/buttons/RecordBlockInitializers.tsx b/packages/core/client/src/schema-initializer/buttons/RecordBlockInitializers.tsx index 2c7eca06c6..c7f11455f7 100644 --- a/packages/core/client/src/schema-initializer/buttons/RecordBlockInitializers.tsx +++ b/packages/core/client/src/schema-initializer/buttons/RecordBlockInitializers.tsx @@ -8,7 +8,7 @@ */ import { Schema } from '@formily/react'; -import { useCallback, useMemo } from 'react'; +import { useCallback } from 'react'; import { useActionAvailable, useCollection, @@ -283,16 +283,6 @@ const commonOptions = { name: 'filterBlocks', title: '{{t("Filter blocks")}}', type: 'itemGroup', - useVisible() { - const collection = useCollection(); - return useMemo( - () => - collection.fields.some( - (field) => canMakeAssociationBlock(field) && ['hasMany', 'belongsToMany'].includes(field.type), - ), - [collection.fields], - ); - }, children: [ { name: 'filterForm',