From 011bba45297f75d5f769e45d20e3f30e2681ece3 Mon Sep 17 00:00:00 2001 From: YANG QIA <2013xile@gmail.com> Date: Mon, 9 Sep 2024 23:24:57 +0800 Subject: [PATCH] fix(data-vi): fix incorrect data source context when multiple data sources exist (#5237) --- .../src/client/configure/schemas/configure.ts | 1 + .../plugin-data-visualization/src/client/hooks/query.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-data-visualization/src/client/configure/schemas/configure.ts b/packages/plugins/@nocobase/plugin-data-visualization/src/client/configure/schemas/configure.ts index 2be9467865..71343fc02d 100644 --- a/packages/plugins/@nocobase/plugin-data-visualization/src/client/configure/schemas/configure.ts +++ b/packages/plugins/@nocobase/plugin-data-visualization/src/client/configure/schemas/configure.ts @@ -215,6 +215,7 @@ export const querySchema: ISchema = { 'x-component-props': { onChange: '{{ onCollectionChange }}', placeholder: '{{t("Collection")}}', + showSearch: true, }, }, }, diff --git a/packages/plugins/@nocobase/plugin-data-visualization/src/client/hooks/query.ts b/packages/plugins/@nocobase/plugin-data-visualization/src/client/hooks/query.ts index d66116e67a..1d906a39d9 100644 --- a/packages/plugins/@nocobase/plugin-data-visualization/src/client/hooks/query.ts +++ b/packages/plugins/@nocobase/plugin-data-visualization/src/client/hooks/query.ts @@ -41,9 +41,10 @@ export type FieldOption = { export const useChartDataSource = (dataSource?: string) => { const { current } = useContext(ChartConfigContext); - const { dataSource: _dataSource = dataSource || DEFAULT_DATA_SOURCE_KEY, collection } = current || {}; + const { dataSource: currentDataSource, collection } = current || {}; + dataSource = dataSource || currentDataSource || DEFAULT_DATA_SOURCE_KEY; const dm = useDataSourceManager(); - const ds = dm.getDataSource(_dataSource); + const ds = dm.getDataSource(dataSource); const fim = dm.collectionFieldInterfaceManager; const cm = ds?.collectionManager; return { cm, fim, collection };