Skip to content

fix(knowledge): prevent navigation on context menu actions and widen tags modal#4015

Merged
waleedlatif1 merged 4 commits intostagingfrom
waleedlatif1/kb-tags-modal-fix
Apr 7, 2026
Merged

fix(knowledge): prevent navigation on context menu actions and widen tags modal#4015
waleedlatif1 merged 4 commits intostagingfrom
waleedlatif1/kb-tags-modal-fix

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Fix KB card context menu actions (view tags, edit, delete) navigating to the KB detail page instead of opening the modal
  • Widen base and document tags modals from sm (400px) to md (500px) for better UX with tag lists

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 7, 2026

PR Summary

Low Risk
Low risk UI-only change that adjusts click handling on the knowledge base card and slightly changes modal sizing; main risk is unintended suppression of navigation in edge click paths.

Overview
Fixes a UX bug where selecting knowledge base card context-menu actions (open in new tab, view tags, edit, delete, copy ID) could also trigger the card click navigation by adding an action guard (actionTakenRef/withActionGuard) and checking it in the card onClick handler.

Widens both the base tags modal and document tags modal by changing ModalContent size from sm to md for improved tag list usability.

Reviewed by Cursor Bugbot for commit 2a82159. Configure here.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 7, 2026 5:46pm

Request Review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 7, 2026

Greptile Summary

Fixes KB card context menu actions (view tags, edit, delete, copy ID) incorrectly triggering card navigation, and widens tag modals from sm (400px) to md (500px).

  • Introduces withActionGuard, a useRef-based helper that sets a flag before running a context menu action and resets it via setTimeout(0) after; handleClick checks this flag to suppress spurious navigation caused by event bubbling
  • Upgrades the reset strategy from requestAnimationFrame to setTimeout(0) for reliable macro-task deferral, addressing prior review feedback
  • Wraps all five context menu handlers (handleOpenInNewTab, handleViewTags, handleEdit, handleDelete, handleCopyId) consistently with the guard
  • Extracts the previously inline onCopyId lambda into a stable handleCopyId useCallback so it also benefits from the guard
  • Changes ModalContent size from 'sm' to 'md' in both BaseTagsModal and DocumentTagsModal for improved tag list readability

Confidence Score: 5/5

Safe to merge — targeted bug fix with a clean ref-guard pattern and no risk of regressions

All three changed files have narrow, well-understood diffs. The guard pattern is sound: the ref is set synchronously before the action runs and reset only after the current macro-task queue drains via setTimeout(0), so handleClick reliably sees the flag during event bubbling. The prior reviewer concern about requestAnimationFrame timing has been addressed. Modal size changes are trivial UX improvements. No new P0 or P1 issues found.

No files require special attention

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/knowledge/components/base-card/base-card.tsx Adds withActionGuard ref-based pattern to prevent context menu actions from triggering card navigation; extracts handleCopyId into a stable useCallback
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/base-tags-modal/base-tags-modal.tsx Modal width widened from sm (400px) to md (500px) for better tag list UX
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/components/document-tags-modal/document-tags-modal.tsx Modal width widened from sm (400px) to md (500px) for better tag list UX

Sequence Diagram

sequenceDiagram
    actor User
    participant Card as KB Card (onClick: handleClick)
    participant CtxMenu as Context Menu Item
    participant Guard as withActionGuard
    participant Ref as actionTakenRef
    participant Timer as Macro-task Queue

    User->>Card: right-click
    Card-->>CtxMenu: context menu opens

    User->>CtxMenu: click item (Edit / Delete / View Tags / Copy ID)
    CtxMenu->>Guard: withActionGuard(fn)
    Guard->>Ref: actionTakenRef.current = true
    Guard->>Guard: fn()
    Guard->>Timer: setTimeout(() => actionTakenRef.current = false, 0)

    Note over Card: click event bubbles up synchronously

    CtxMenu-->>Card: click bubbles → handleClick(e)
    Card->>Ref: read actionTakenRef.current
    Ref-->>Card: true

    Card->>Card: e.preventDefault() — no navigation
    Card-->>User: action modal opens instead

    Note over Timer: macro-task executes later

    Timer->>Ref: actionTakenRef.current = false
Loading

Reviews (3): Last reviewed commit: "fix(knowledge): wrap withActionGuard cal..." | Re-trigger Greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2a82159. Configure here.

@waleedlatif1 waleedlatif1 merged commit 5c7b057 into staging Apr 7, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/kb-tags-modal-fix branch April 7, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant