You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by jl...@apache.org on 2026/10/15 18:02:19 UTC
(superset) 01/01: fix(dashboard): stop Edit Properties hanging on dashboards with many charts
This is an automated email from the ASF dual-hosted git repository.
sadpandajoe pushed a commit to branch ultraset-edit-properties-dashboard-many-charts-hang
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 5ab28e34d565ab6b802b10eace6cfbdfd95f9c57
Author: Joe Li <47...@users.noreply.github.com>
AuthorDate: Thu Oct 15 17:57:36 2026 +0000
fix(dashboard): stop Edit Properties hanging on dashboards with many charts
The dashboard properties modal put the whole dashboard info, including
`metadata`, into the antd form store through `form.setFieldsValue` and
`initialValues`. No form field reads `metadata`, but hydration gives every
interactive chart a `chartsInScope` list of all the other charts, so
`metadata.chart_configuration` grows with the square of the chart count.
rc-field-form deep-merges everything it is given, copying the parent array for
each leaf, which made opening the modal (and every later `setFieldsValue`,
such as the inline-title sync) cost roughly the cube of the chart count: about
12s at 333 charts in jsdom, versus well under a second without the metadata.
Keep `metadata` out of the form store; it is still held in component state for
the JSON editor and the other sections.
Fixes #45339
Co-Authored-By: Claude Sonnet 5.5 <no...@anthropic.com>
---
.../PropertiesModal.manyCharts.test.tsx | 107 +++++++++++++++++++++
.../dashboard/components/PropertiesModal/index.tsx | 8 +-
2 files changed, 112 insertions(+), 3 deletions(-)
diff --git a/superset-frontend/src/dashboard/components/PropertiesModal/PropertiesModal.manyCharts.test.tsx b/superset-frontend/src/dashboard/components/PropertiesModal/PropertiesModal.manyCharts.test.tsx
new file mode 100644
index 00000000000..9a992d1fd95
--- /dev/null
+++ b/superset-frontend/src/dashboard/components/PropertiesModal/PropertiesModal.manyCharts.test.tsx
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { render, screen, waitFor } from 'spec/helpers/testing-library';
+import fetchMock from 'fetch-mock';
+import { Form } from '@superset-ui/core/components';
+import PropertiesModal from '.';
+
+jest.mock('@superset-ui/core', () => ({
+ ...jest.requireActual('@superset-ui/core'),
+ isFeatureEnabled: jest.fn(() => false),
+ getCategoricalSchemeRegistry: jest.fn(() => ({
+ keys: () => ['supersetColors'],
+ get: () => ['#FFFFFF', '#000000'],
+ getDefaultKey: () => 'supersetColors',
+ getMap: () => ({}),
+ })),
+}));
+
+fetchMock.get('glob:*/api/v1/theme/*', { body: { result: [] } });
+
+afterAll(() => {
+ fetchMock.clearHistory().removeRoutes();
+});
+
+// Hydration gives every interactive chart a `chartsInScope` list of all the
+// other charts, so `chart_configuration` grows with the square of the chart
+// count.
+const buildDashboardInfo = (chartCount: number) => {
+ const chartIds = Array.from({ length: chartCount }, (_, i) => i + 1);
+ const chartConfiguration = Object.fromEntries(
+ chartIds.map(id => [
+ id,
+ {
+ id,
+ crossFilters: {
+ scope: 'global',
+ chartsInScope: chartIds.filter(other => other !== id),
+ },
+ },
+ ]),
+ );
+ return {
+ id: 26,
+ dashboard_title: 'Many charts',
+ slug: null,
+ css: '',
+ certified_by: '',
+ certification_details: '',
+ editors: [],
+ viewers: [],
+ metadata: {
+ refresh_frequency: 0,
+ chart_configuration: chartConfiguration,
+ global_chart_configuration: {
+ scope: { rootPath: ['ROOT_ID'], excluded: [] },
+ chartsInScope: chartIds,
+ },
+ },
+ };
+};
+
+test('does not copy dashboard metadata into the form store on dashboards with many charts', async () => {
+ // antd's form store deep-merges every value it is given, which is cubic in
+ // the chart count for `chart_configuration`; no form field reads `metadata`.
+ const useFormSpy = jest.spyOn(Form, 'useForm');
+
+ render(
+ <PropertiesModal
+ dashboardId={26}
+ dashboardInfo={buildDashboardInfo(333)}
+ dashboardTitle="Renamed inline"
+ show
+ onlyApply
+ onHide={jest.fn()}
+ onSubmit={jest.fn()}
+ addSuccessToast={jest.fn()}
+ />,
+ { useRedux: true },
+ );
+
+ await waitFor(() =>
+ expect(screen.getByTestId('dashboard-title-input')).toHaveValue(
+ 'Renamed inline',
+ ),
+ );
+
+ const [form] = useFormSpy.mock.results[0].value;
+ expect(Object.keys(form.getFieldsValue(true))).not.toContain('metadata');
+ expect(form.getFieldValue('title')).toBe('Renamed inline');
+ useFormSpy.mockRestore();
+});
diff --git a/superset-frontend/src/dashboard/components/PropertiesModal/index.tsx b/superset-frontend/src/dashboard/components/PropertiesModal/index.tsx
index a10228ce274..86ab32a17bb 100644
--- a/superset-frontend/src/dashboard/components/PropertiesModal/index.tsx
+++ b/superset-frontend/src/dashboard/components/PropertiesModal/index.tsx
@@ -216,7 +216,9 @@ const PropertiesModal = ({
metadata,
};
- form.setFieldsValue(dashboardInfo);
+ // `metadata` has no form field and can be huge on dashboards with many
+ // charts; the form store deep-merges everything it is given.
+ form.setFieldsValue(omit(dashboardInfo, 'metadata'));
setDashboardInfo(dashboardInfo);
setEditors(editors || []);
setViewers(viewers || []);
@@ -542,7 +544,7 @@ const PropertiesModal = ({
dashboardInfo.title !== dashboardTitle
) {
form.setFieldsValue({
- ...dashboardInfo,
+ ...omit(dashboardInfo, 'metadata'),
title: dashboardTitle,
});
}
@@ -764,7 +766,7 @@ const PropertiesModal = ({
}}
data-test="dashboard-edit-properties-form"
layout="vertical"
- initialValues={dashboardInfo}
+ initialValues={dashboardInfo && omit(dashboardInfo, 'metadata')}
>
<Collapse
expandIconPosition="end"