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


##########
superset-frontend/src/features/home/Menu.tsx:
##########
@@ -238,7 +244,7 @@ export function Menu({
       case path.startsWith(Paths.Chart) || path.startsWith(Paths.Explore):
         setActiveTabs([MenuKeys.Charts]);
         break;
-      case path.startsWith(Paths.Datasets):
+      case path.startsWith(Paths.Datasets) || path.startsWith(Paths.Dataset):

Review Comment:
   **Suggestion:** The bare `startsWith('/dataset')` check also matches 
unrelated paths such as `/datasets` and `/datasetting`, causing the Datasets 
tab to appear active on those routes. Match the `/dataset` path as a segment, 
such as `/dataset/` or the exact `/dataset`, so only the dataset routes are 
selected. [incorrect condition logic]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Unrelated `/dataset*` pages show Datasets as active.
   - ⚠️ Navbar state becomes incorrect outside dataset workflows.
   - ⚠️ Future routes sharing this prefix inherit the false highlight.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Render the navbar `Menu` component from
   `superset-frontend/src/features/home/Menu.tsx:237-240`; it reads 
`location.pathname` into
   `path` and evaluates the active-tab switch whenever the browser pathname 
changes.
   
   2. Navigate directly to a pathname such as `/datasetting` or `/datasets`; 
this pathname is
   not one of the registered modern dataset routes in
   `superset-frontend/src/views/routePaths.ts:46-47`, which define only 
`/dataset/add/` and
   `/dataset/:datasetId`.
   
   3. At `superset-frontend/src/features/home/Menu.tsx:247`, 
`path.startsWith(Paths.Dataset)`
   evaluates true because `Paths.Dataset` is `/dataset`, even though the 
pathname is not on
   the `/dataset` route boundary.
   
   4. The switch sets `activeTabs` to `MenuKeys.Datasets` at
   `superset-frontend/src/features/home/Menu.tsx:248`, causing the Datasets 
navigation item
   to appear selected on an unrelated path. Match the exact path or a 
slash-delimited segment
   instead, such as `/dataset` or `/dataset/`.
   ```
   </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=bc0622ceb7e74863b53ebb208da47d4b&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=bc0622ceb7e74863b53ebb208da47d4b&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/features/home/Menu.tsx
   **Line:** 247:247
   **Comment:**
        *Incorrect Condition Logic: The bare `startsWith('/dataset')` check 
also matches unrelated paths such as `/datasets` and `/datasetting`, causing 
the Datasets tab to appear active on those routes. Match the `/dataset` path as 
a segment, such as `/dataset/` or the exact `/dataset`, so only the dataset 
routes are selected.
   
   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%2F42529&comment_hash=6c70d3e52d6ad1258813b8fefe43ddefd5fe93eafcbf5f320406fb3012759d44&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42529&comment_hash=6c70d3e52d6ad1258813b8fefe43ddefd5fe93eafcbf5f320406fb3012759d44&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