This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch default_chart_settings
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 120dd2a371041f2188626628ad81ce758a71fecb
Author: Maxime Beauchemin <maximebeauche...@gmail.com>
AuthorDate: Sun Aug 3 21:11:11 2025 -0700

    fix: Move Chart Defaults outside Fieldset to prevent onChange override
    
    CRITICAL FIX: The Fieldset component was also overriding our onChange
    handlers, preventing chart defaults from working.
    
    Root cause: Fieldset uses recurseReactClone to inject its own onChange
    handler that expects simple fields like item.fieldKey, but our chart
    defaults are nested inside item.extra.default_chart_metadata.
    
    Solution:
    - Moved Chart Defaults section outside of Fieldset component
    - Used Form.Item with Typography.Title for the section header
    - This allows Field components to use our custom onChange handlers
    
    Now the data flow works correctly:
    Field onChange → onChartDefaultChange → parse/update extra JSON →
    onDatasourcePropChange → state update → modal notification
    
    🤖 Generated with [Claude Code](https://claude.ai/code)
    
    Co-Authored-By: Claude <nore...@anthropic.com>
---
 .../src/components/Datasource/DatasourceEditor.jsx    | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/superset-frontend/src/components/Datasource/DatasourceEditor.jsx 
b/superset-frontend/src/components/Datasource/DatasourceEditor.jsx
index f60538959d..31ad3a7b89 100644
--- a/superset-frontend/src/components/Datasource/DatasourceEditor.jsx
+++ b/superset-frontend/src/components/Datasource/DatasourceEditor.jsx
@@ -54,6 +54,7 @@ import {
   Col,
   Divider,
   EditableTitle,
+  Form,
   FormLabel,
   Icons,
   Loading,
@@ -1091,11 +1092,10 @@ class DatasourceEditor extends PureComponent {
             }}
           />
         </Fieldset>
-        <Fieldset
-          title={t('Chart Defaults')}
-          item={datasource}
-          onChange={this.onDatasourceChange}
-        >
+        <Form.Item>
+          <Typography.Title level={5}>
+            {t('Chart Defaults')} <Divider />
+          </Typography.Title>
           <Field
             fieldKey="default_metric"
             label={t('Default Metric')}
@@ -1106,9 +1106,10 @@ class DatasourceEditor extends PureComponent {
               parseExtra(datasource.extra).default_chart_metadata
                 ?.default_metric
             }
-            onChange={(fieldKey, value) =>
-              this.onChartDefaultChange('default_metric', value)
-            }
+            onChange={(fieldKey, value) => {
+              console.log('Field onChange called with:', fieldKey, value);
+              this.onChartDefaultChange('default_metric', value);
+            }}
             control={
               <Select
                 name="default_metric"
@@ -1258,7 +1259,7 @@ class DatasourceEditor extends PureComponent {
               />
             }
           />
-        </Fieldset>
+        </Form.Item>
       </>
     );
   }

Reply via email to