You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "gabotorresruiz (via GitHub)" <gi...@apache.org> on 2025/10/10 20:09:56 UTC

[PR] fix(ag-grid): fix conditional formatting theme colors and module extensibility [superset]

gabotorresruiz opened a new pull request, #35605:
URL: https://github.com/apache/superset/pull/35605

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   This PR fixes theme-switching issues in the AG Grid Table V2 chart, adds some visual enhancements and improves code organization:
   
   1. **Fixed conditional formatting colors freezing on theme switch**: When users applied conditional formatting with built-in color schemes (success/alert/error) and switched between light and dark themes, the cell background colors would remain frozen with the hex value from the original theme, making text unreadable. The fix ensures color schemes are stored as theme token references and resolved dynamically at render time based on the current theme.
   
   2. **Fixed thumbnail theme mismatch**: The thumbnail images for `Table V2` were showing the opposite theme (light mode showed dark thumbnail and vice versa). The PNG files were physically swapped to correct this.
   
   3. **Improved module system extensibility**: added `defaultModules`, which are the default `AG Grid` modules registered when calling `setupAGGridModules()`.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   #### Thumbnail Theme Mismatch Fix
   Before:
   <img width="1110" height="766" alt="Screenshot 2025-10-10 at 15 52 55" src="https://github.com/user-attachments/assets/d623c8ff-ef6e-426a-8b70-c34d31298b89" />
   <img width="1117" height="768" alt="Screenshot 2025-10-10 at 15 50 39" src="https://github.com/user-attachments/assets/26e9ca18-7639-4379-bb23-3d3d1037d19d" />
   
   After:
   <img width="1107" height="768" alt="Screenshot 2025-10-10 at 16 02 37" src="https://github.com/user-attachments/assets/4682a1ee-6c20-42d5-be2d-6fd58b3cc4a5" />
   <img width="1117" height="768" alt="Screenshot 2025-10-10 at 15 24 55" src="https://github.com/user-attachments/assets/9c954008-1155-41cd-b8f5-5eb9711a43ac" />
   
   #### Conditional Formatting Theme-Switching Fix:
   Before
   ![before-bad-bar-colors](https://github.com/user-attachments/assets/cf4d800e-defa-41ac-9217-eb9ddf4f749a)
   
   After
   ![correct-bar-color-after](https://github.com/user-attachments/assets/ea62c822-c0d1-463d-bcff-bac928988c5a)
   
   #### Visual enhancements
   Before (Not vertically centered)
   <img width="313" height="150" alt="Screenshot 2025-10-10 at 16 06 40" src="https://github.com/user-attachments/assets/6c7bd461-302c-4f95-b537-a2a6b4ce13ad" />
   
   After (Vertically centered)
   <img width="329" height="150" alt="Screenshot 2025-10-10 at 15 27 16" src="https://github.com/user-attachments/assets/035c02de-e097-4528-aaf8-a260a9df402c" />
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   #### Test 1: Thumbnail Theme Mismatch Fix
   1. Make sure `"AG_GRID_TABLE_ENABLED": True` in `superset/config.py`
   2. Switch to **light mode**
   3. Go to **Charts** → **+ Chart**
   4. Choose chart type: `Table`
   5. Find **Table V2** visualization type
   6. Verify the thumbnail shows a **light theme table** (white background)
   7. Switch to **dark mode**
   8. Verify the thumbnail shows a **dark theme table** (dark background)
   
   #### Test 2: Conditional Formatting Theme-Switching Fix
   1. Create a new **Table V2** chart with a numeric metric (e.g., `SUM(num)` from `examples.birth_names`)
   2. Go to **Customize** tab → **Conditional formatting**
   3. Click **+ Add new color formatter**
   4. Configure:
      - **Column**: Select your metric column
      - **Color scheme**: Select **alert** (warning colors)
      - **Operator**: Select **None** (applies to all values)
   5. Click **Apply** and **Update Chart**
   6. In **dark mode**: Verify cells have dark brown background with readable white text
   7. Switch to **light mode** (user menu → theme toggle)
   8. Verify cells now have light yellow background with readable dark text
   9. Switch back to **dark mode**
   10. Verify cells return to dark brown background
   11. Repeat steps 2-10 with **success** and **error** color schemes
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(ag-grid): fix conditional formatting theme colors and module extensibility [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on PR #35605:
URL: https://github.com/apache/superset/pull/35605#issuecomment-3407531894

   @amaannawab923 Can i have your eyes on this? Thanks!


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(ag-grid): fix conditional formatting theme colors and module extensibility [superset]

Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on code in PR #35605:
URL: https://github.com/apache/superset/pull/35605#discussion_r2421994849


##########
superset-frontend/packages/superset-ui-core/src/components/ThemedAgGridReact/setupAGGridModules.ts:
##########
@@ -39,27 +40,29 @@ import {
 } from 'ag-grid-community';
 
 /**
- * Registers the AG-Grid modules required for Superset's table functionality.
- * This should be called once during application initialization.
+ * Default AG Grid modules that are registered by default.
+ * These modules provide core AG Grid functionality.
  */
-export const setupAGGridModules = () => {
-  ModuleRegistry.registerModules([
-    ColumnAutoSizeModule,
-    ColumnHoverModule,
-    RowAutoHeightModule,
-    RowStyleModule,
-    PaginationModule,
-    CellStyleModule,
-    TextFilterModule,
-    NumberFilterModule,
-    DateFilterModule,
-    ExternalFilterModule,
-    CsvExportModule,
-    ColumnApiModule,
-    RowApiModule,
-    CellApiModule,
-    RenderApiModule,
-    ClientSideRowModelModule,
-    CustomFilterModule,
-  ]);
+export const defaultModules: Module[] = [
+  ColumnAutoSizeModule,
+  ColumnHoverModule,
+  RowAutoHeightModule,
+  RowStyleModule,
+  PaginationModule,
+  CellStyleModule,
+  TextFilterModule,
+  NumberFilterModule,
+  DateFilterModule,
+  ExternalFilterModule,
+  CsvExportModule,
+  ColumnApiModule,
+  RowApiModule,
+  CellApiModule,
+  RenderApiModule,
+  ClientSideRowModelModule,
+  CustomFilterModule,
+];
+
+export const setupAGGridModules = (additionalModules: Module[] = []) => {
+  ModuleRegistry.registerModules([...defaultModules, ...additionalModules]);

Review Comment:
   ### Inefficient array spreading in module registration <sub>![category Performance](https://img.shields.io/badge/Performance-4f46e5)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The spread operator creates unnecessary array copies when merging defaultModules and additionalModules arrays.
   
   
   ###### Why this matters
   This creates temporary arrays in memory and performs additional iterations, which could impact performance when called frequently or with large module arrays.
   
   ###### Suggested change ∙ *Feature Preview*
   Use `ModuleRegistry.registerModules(defaultModules.concat(additionalModules))` or call `registerModules` twice separately to avoid creating intermediate arrays:
   ```typescript
   ModuleRegistry.registerModules(defaultModules);
   if (additionalModules.length > 0) {
     ModuleRegistry.registerModules(additionalModules);
   }
   ```
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/d5853cb0-6a79-4c34-9b0a-8f12a75c4b2f/upvote) [![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/d5853cb0-6a79-4c34-9b0a-8f12a75c4b2f?what_not_true=true)  [![Not in Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/d5853cb0-6a79-4c34-9b0a-8f12a75c4b2f?what_out_of_scope=true) [![Not in coding standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/d5853cb0-6a79-4c34-9b0a-8f12a75c4b2f?what_not_in_standard=true) [![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/d5853cb0-6a79-4c34-9b0a-8f12a75c4b2f)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:9758015b-e7b5-44a6-809a-ab36bc14a022 -->
   
   
   [](9758015b-e7b5-44a6-809a-ab36bc14a022)



##########
superset-frontend/src/explore/components/controls/ConditionalFormattingControl/FormattingPopoverContent.tsx:
##########
@@ -56,10 +56,11 @@ const JustifyEnd = styled.div`
   justify-content: flex-end;
 `;
 
-const colorSchemeOptions = (theme: SupersetTheme) => [
-  { value: theme.colorSuccessBg, label: t('success') },
-  { value: theme.colorWarningBg, label: t('alert') },
-  { value: theme.colorErrorBg, label: t('error') },
+// Use theme token names instead of hex values to support theme switching
+const colorSchemeOptions = () => [
+  { value: 'colorSuccessBg', label: t('success') },
+  { value: 'colorWarningBg', label: t('alert') },
+  { value: 'colorErrorBg', label: t('error') },
 ];

Review Comment:
   ### Theme token names not resolved to actual colors <sub>![category Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The colorSchemeOptions function now returns theme token names as strings instead of actual color values, but there's no mechanism to resolve these token names to actual colors when they're used.
   
   
   ###### Why this matters
   The conditional formatting will receive string token names like 'colorSuccessBg' instead of actual color values, causing the formatting to fail or display incorrectly since the consuming components expect actual color values.
   
   ###### Suggested change ∙ *Feature Preview*
   Either resolve the theme tokens to actual colors within this component by keeping the theme parameter and accessing theme properties, or ensure that the consuming components can handle theme token names and resolve them appropriately:
   
   ```typescript
   const colorSchemeOptions = (theme: SupersetTheme) => [
     { value: theme.colorSuccessBg, label: t('success') },
     { value: theme.colorWarningBg, label: t('alert') },
     { value: theme.colorErrorBg, label: t('error') },
   ];
   
   // And restore the theme usage:
   const theme = useTheme();
   const colorScheme = colorSchemeOptions(theme);
   ```
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c54b7564-e2dd-49f4-bf03-590a8590e4ca/upvote) [![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c54b7564-e2dd-49f4-bf03-590a8590e4ca?what_not_true=true)  [![Not in Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c54b7564-e2dd-49f4-bf03-590a8590e4ca?what_out_of_scope=true) [![Not in coding standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c54b7564-e2dd-49f4-bf03-590a8590e4ca?what_not_in_standard=true) [![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c54b7564-e2dd-49f4-bf03-590a8590e4ca)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:60bb175a-35a6-41c7-a3f3-7b2a81d8a439 -->
   
   
   [](60bb175a-35a6-41c7-a3f3-7b2a81d8a439)



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(ag-grid): fix conditional formatting theme colors and module extensibility [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #35605:
URL: https://github.com/apache/superset/pull/35605#discussion_r2430633642


##########
superset-frontend/src/explore/components/controls/ConditionalFormattingControl/FormattingPopoverContent.tsx:
##########
@@ -56,10 +56,11 @@ const JustifyEnd = styled.div`
   justify-content: flex-end;
 `;
 
-const colorSchemeOptions = (theme: SupersetTheme) => [
-  { value: theme.colorSuccessBg, label: t('success') },
-  { value: theme.colorWarningBg, label: t('alert') },
-  { value: theme.colorErrorBg, label: t('error') },
+// Use theme token names instead of hex values to support theme switching
+const colorSchemeOptions = () => [

Review Comment:
   will this break conditional formatting for other charts like table, bigNumber, etc?



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(ag-grid): fix conditional formatting theme colors and module extensibility [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on code in PR #35605:
URL: https://github.com/apache/superset/pull/35605#discussion_r2448481250


##########
superset-frontend/plugins/plugin-chart-ag-grid-table/src/transformProps.ts:
##########
@@ -494,6 +495,36 @@ const transformProps = (
 
   const allowRearrangeColumns = true;
 
+  // Calculate time comparison settings early since they're used in multiple places

Review Comment:
   Do we add any early usages? I am ok with this but don't understand why it's changed



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(ag-grid): fix conditional formatting theme colors and module extensibility [superset]

Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho merged PR #35605:
URL: https://github.com/apache/superset/pull/35605


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(ag-grid): fix conditional formatting theme colors and module extensibility [superset]

Posted by "gabotorresruiz (via GitHub)" <gi...@apache.org>.
gabotorresruiz commented on code in PR #35605:
URL: https://github.com/apache/superset/pull/35605#discussion_r2450357971


##########
superset-frontend/plugins/plugin-chart-ag-grid-table/src/transformProps.ts:
##########
@@ -494,6 +495,36 @@ const transformProps = (
 
   const allowRearrangeColumns = true;
 
+  // Calculate time comparison settings early since they're used in multiple places

Review Comment:
   This is just an `eslint` fix to not use a function before it's define



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(ag-grid): fix conditional formatting theme colors and module extensibility [superset]

Posted by "gabotorresruiz (via GitHub)" <gi...@apache.org>.
gabotorresruiz commented on code in PR #35605:
URL: https://github.com/apache/superset/pull/35605#discussion_r2433591483


##########
superset-frontend/src/explore/components/controls/ConditionalFormattingControl/FormattingPopoverContent.tsx:
##########
@@ -56,10 +56,11 @@ const JustifyEnd = styled.div`
   justify-content: flex-end;
 `;
 
-const colorSchemeOptions = (theme: SupersetTheme) => [
-  { value: theme.colorSuccessBg, label: t('success') },
-  { value: theme.colorWarningBg, label: t('alert') },
-  { value: theme.colorErrorBg, label: t('error') },
+// Use theme token names instead of hex values to support theme switching
+const colorSchemeOptions = () => [

Review Comment:
   This is actually a pretty nice catch. Let me check. Thanks @sadpandajoe 



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org