codeant-ai-for-open-source[bot] commented on code in PR #37777:
URL: https://github.com/apache/superset/pull/37777#discussion_r3488487331


##########
superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.tsx:
##########
@@ -189,13 +189,17 @@ export const DataTablesPane = ({
     ownState,
     isRequest: isRequest.results,
     setForceQuery,
-    isVisible: ResultTypes.Results === activeTabKey,
     canDownload,
-  }).map((pane, idx) => ({
-    key: idx === 0 ? ResultTypes.Results : `${ResultTypes.Results} ${idx + 1}`,
-    label: idx === 0 ? t('Results') : t('Results %s', idx + 1),
-    children: pane,
-  }));
+  }).map((pane, idx) => {
+    const tabKey =
+      idx === 0 ? ResultTypes.Results : `${ResultTypes.Results} ${idx + 1}`;
+
+    return {
+      key: tabKey,
+      label: idx === 0 ? t('Results') : t('Results %s', idx + 1),
+      children: activeTabKey === tabKey ? pane : null,

Review Comment:
   **Suggestion:** Conditionally nulling each tab’s content based only on the 
current key can leave all result tabs empty when the selected key becomes stale 
(for example after rerunning a mixed chart that now returns fewer result 
panes). In that state, no table is rendered until the user manually reselects a 
valid tab. Reset the active key to an existing tab when pane count changes, or 
keep tab content attached and rely on tab-pane lifecycle props to unmount 
inactive panes. [incorrect condition logic]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Explore DataTablesPane shows blank area after rerunning mixed chart.
   - ⚠️ Users think no results returned though data exists.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Open a mixed chart with multiple queries in Explore so that 
`ExploreChartPanel` renders
   `DataTablesPane` alongside the chart
   
(`superset-frontend/src/explore/components/ExploreChartPanel/index.tsx:553-563` 
shows the
   `<DataTablesPane ... />` usage).
   
   2. Open the Data panel, click on the second results tab (labelled “Results 
2”), which
   calls `handleTabClick` in `DataTablesPane`
   
(`superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.tsx:143-151`)
 and
   sets `activeTabKey` to the string `"results 2"`.
   
   3. Change the chart configuration so it now only produces a single query 
result (for
   example, by switching from a mixed chart with multiple query objects to one 
that only has
   a single query) and re-run the chart; `useResultsPane`
   (`components/useResultsPane.tsx:48-192`) will now return an array with only 
one result
   pane, and `queryResultsPanes` in `DataTablesPane` 
(`DataTablesPane.tsx:185-193`) will only
   contain the tab with key `"results"`.
   
   4. After the re-render, the `Tabs` component in `DataTablesPane`
   (`DataTablesPane.tsx:225-231`) is passed `items` containing keys `"results"` 
and
   `"samples"`, but `activeKey` remains `"results 2"`, and each results tab’s 
`children` is
   set via `children: activeTabKey === tabKey ? pane : null` 
(`DataTablesPane.tsx:200`);
   because no item has key `"results 2"`, Ant Design Tabs renders no active tab 
pane and the
   content area is blank until the user manually clicks the “Results” tab to 
reset
   `activeTabKey`.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=fdcbea96d68641f697da5224e30dbb26&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=fdcbea96d68641f697da5224e30dbb26&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.tsx
   **Line:** 200:200
   **Comment:**
        *Incorrect Condition Logic: Conditionally nulling each tab’s content 
based only on the current key can leave all result tabs empty when the selected 
key becomes stale (for example after rerunning a mixed chart that now returns 
fewer result panes). In that state, no table is rendered until the user 
manually reselects a valid tab. Reset the active key to an existing tab when 
pane count changes, or keep tab content attached and rely on tab-pane lifecycle 
props to unmount inactive panes.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37777&comment_hash=a9b45786ea69d4e7820872427e421cf8178a65428ea94d02fde5a91d53388d05&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37777&comment_hash=a9b45786ea69d4e7820872427e421cf8178a65428ea94d02fde5a91d53388d05&reaction=dislike'>👎</a>



-- 
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