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

   ### SUMMARY
   
   This PR fixes two issues with the World Map chart:
   
   1. **Right-click error** (`TypeError: onContextMenu is not a function`)
   2. **Row count shows "0 rows"** for legacy charts
   
   ### Issue 1: Right-Click Error
   
   **Symptoms**: Right-clicking on any country throws `TypeError: onContextMenu 
is not a function`
   
   **Root Cause**: The `onContextMenu` hook is called without a null check in 
`WorldMap.ts`. This hook is only provided when charts are rendered on a 
Dashboard with the `DrillToDetail` feature flag enabled. In other contexts 
(e.g., Explore view), `onContextMenu` is `undefined`.
   
   **Fix**: Added defensive guard before calling `onContextMenu`:
   
   ```
   if (onContextMenu) {
     onContextMenu(pointerEvent.clientX, pointerEvent.clientY, { ... });
   }
   
   ```
   
   ### Issue 2: Row Count Shows "0 rows"
   
   **Symptoms**: Legacy charts display "0 rows" despite rendering data correctly
   
   **Root Cause**: The frontend expects `sql_rowcount` from query responses, 
but legacy charts (using `useLegacyApi: true`) only return `rowcount`. Both 
values are computed identically in the backend (`len(df.index)`), but the 
legacy API in `viz.py` doesn't include `sql_rowcount`.
   
   **Fix**: Updated frontend components to fall back to `rowcount` when 
`sql_rowcount` is unavailable:
   
   ```
   sql_rowcount ?? rowcount ?? 0
   
   ```
   
   **Impact**: This fix benefits all 16 legacy chart plugins that use 
`useLegacyApi: true`, not just World Map.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   #### BEFORE
   
   
https://github.com/user-attachments/assets/d20c6ac0-f919-49a4-b564-781e6bd1369b
   
   #### AFTER
   
   
https://github.com/user-attachments/assets/3ef4ee3a-0450-4f9a-be59-33d62d806395
   
   
   ### TESTING INSTRUCTIONS
   
   1. Create a World Map chart with country data
   2. Verify right-click doesn't crash in Explore view
   3. Verify right-click shows context menu on Dashboard (with DrillToDetail 
enabled)
   4. Verify row count displays actual number of rows
   
   ### 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:
   - [ ] 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: [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