From b338c51923b125fc82f10197a476333d35e34198 Mon Sep 17 00:00:00 2001 From: sealday Date: Wed, 22 May 2024 01:36:55 +0800 Subject: [PATCH] fix: duplicated designer setting items (#1028) Co-authored-by: sealday Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/1028 --- .../client/src/application/schema-settings/SchemaSettings.tsx | 1 - .../client/src/application/schema-settings/hooks/index.tsx | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/client/src/application/schema-settings/SchemaSettings.tsx b/packages/core/client/src/application/schema-settings/SchemaSettings.tsx index 45f6d7969..595f3f63b 100644 --- a/packages/core/client/src/application/schema-settings/SchemaSettings.tsx +++ b/packages/core/client/src/application/schema-settings/SchemaSettings.tsx @@ -11,7 +11,6 @@ export class SchemaSettings { constructor(options: SchemaSettingOptions) { this.options = Object.assign({ items: [] }, options); - this.options.items = defaultSettingItems.concat(this.items); this.name = options.name; } diff --git a/packages/core/client/src/application/schema-settings/hooks/index.tsx b/packages/core/client/src/application/schema-settings/hooks/index.tsx index aefc9841b..c6149ef22 100644 --- a/packages/core/client/src/application/schema-settings/hooks/index.tsx +++ b/packages/core/client/src/application/schema-settings/hooks/index.tsx @@ -7,6 +7,7 @@ import { SchemaSettingsProps } from '../../../schema-settings'; import { Schema } from '@tachybase/schema'; import { GeneralField } from '@tachybase/schema'; import { Designable } from '../../../schema-component'; +import { defaultSettingItems } from '../SchemaSettingsDefaults'; type UseSchemaSettingsRenderOptions = Omit, 'name' | 'items'> & Omit & { @@ -40,8 +41,9 @@ export function useSchemaSettingsRender(name: string, options?: UseSchem if (key && renderCache.current[key]) { return renderCache.current[key]; } + const newItems = [...defaultSettingItems, ...schemaSetting.options.items]; return (renderCache.current[key] = React.createElement(SchemaSettingsWrapper, { - ...schemaSetting.options, + ...{ ...schemaSetting.options, items: newItems }, ...options, ...options2, }));