Vitor-Avila commented on code in PR #33196:
URL: https://github.com/apache/superset/pull/33196#discussion_r2059485470


##########
superset-frontend/src/explore/components/ExploreViewContainer/index.jsx:
##########
@@ -768,6 +779,30 @@ function mapStateToProps(state) {
     dashboardId = undefined;
   }
 
+  if (
+    form_data.viz_type === 'big_number_total' &&
+    slice?.form_data?.subheader &&
+    (!controls.subtitle?.value || controls.subtitle.value === '')
+  ) {
+    controls.subtitle = {
+      ...controls.subtitle,
+      value: slice.form_data.subheader,
+    };
+  }
+  if (
+    form_data.viz_type === 'big_number_total' &&
+    slice?.form_data?.subheader_font_size &&
+    (!controls.subtitle_font_size?.value ||
+      controls.subtitle_font_size.value === '')
+  ) {
+    controls.subtitle_font_size = {
+      ...controls.subtitle_font_size,
+      value: slice.form_data.subheader_font_size,
+    };
+  }

Review Comment:
   I'm suggesting this change for two reasons:
   - It moves the second change (`controls.subtitle_font_size =  
slice.form_data.subheader_font_size`) as part of the first `if` block. This is 
mostly because if the chart has a `subheader` config and does not have a 
`subtitle` config, then `subheader_font_size` should be the source of truth. 
For safety, just checking if `slice?.form_data?.subheader_font_size` exists.
   - In the current implementation, `!controls.subtitle_font_size?.value` is 
evaluated. I believe `controls.subtitle_font_size` always gets a default value, 
so that second `if` would never really execute and instead the old `subheader` 
ends up with the default size.
   
   
   ```suggestion
     if (
       form_data.viz_type === 'big_number_total' &&
       slice?.form_data?.subheader &&
       (!controls.subtitle?.value || controls.subtitle.value === '')
     ) {
       controls.subtitle = {
         ...controls.subtitle,
         value: slice.form_data.subheader,
       };
       if (slice?.form_data?.subheader_font_size) {
         controls.subtitle_font_size = {
           ...controls.subtitle_font_size,
           value: slice.form_data.subheader_font_size,
         };
       }
     }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to