Skip to content

Fix: Adds safeguards to the table's click handlers#4540

Open
ashrafchowdury wants to merge 4 commits into
mainfrom
hotfix/table-cell-click-issue
Open

Fix: Adds safeguards to the table's click handlers#4540
ashrafchowdury wants to merge 4 commits into
mainfrom
hotfix/table-cell-click-issue

Conversation

@ashrafchowdury
Copy link
Copy Markdown
Contributor

Summary

Adds safeguards to the table's click handling so clicks on unintended or wrong cells are ignored. This prevents accidental actions and improves the reliability of cell interactions.

Behavior

Clicks that don't land on a valid, intended cell are now safely ignored instead of triggering unwanted handlers.

closes #3254

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 3, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 3, 2026

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

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment Jun 5, 2026 9:24am

Request Review

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jun 3, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • New Features

    • Added optional disableInteractiveClickGuard prop to control click event behavior in table interactions.
  • Bug Fixes

    • Improved click handling in tables to prevent unintended row navigation when clicking action dropdowns or interactive elements within rows.
  • Chores

    • Refactored click event propagation logic for better maintainability.

Walkthrough

This PR improves table row-click behavior by centralizing interactive element detection and integrating click guards that prevent row navigation when clicks originate from interactive UI elements like buttons, checkboxes, and dropdowns across both the oss and agenta-ui table components.

Changes

Table Click Behavior Improvements

Layer / File(s) Summary
Interactive element detection refactoring
web/oss/src/components/InfiniteVirtualTable/hooks/useTableManager.tsx, web/packages/agenta-ui/src/InfiniteVirtualTable/hooks/useTableManager.tsx
Introduces a consolidated INTERACTIVE_SELECTOR CSS selector constant and refactors shouldIgnoreRowClick to use a single closest() check instead of separate element/class checks.
InfiniteVirtualTable props and types
web/oss/src/components/InfiniteVirtualTable/types.ts, web/packages/agenta-ui/src/InfiniteVirtualTable/types.ts
Adds optional disableInteractiveClickGuard boolean prop to InfiniteVirtualTableProps with documentation describing its effect on interactive element click guarding.
InfiniteVirtualTable row click guard wiring
web/oss/src/components/InfiniteVirtualTable/components/InfiniteVirtualTableInner.tsx, web/packages/agenta-ui/src/InfiniteVirtualTable/components/InfiniteVirtualTableInner.tsx
Integrates shouldIgnoreRowClick into row click handlers: adds prop default, merges base and selection clicks, conditionally wraps handler with ignore-check logic, and updates memoization conditions based on guard state.
Actions column click propagation
web/oss/src/components/InfiniteVirtualTable/columns/createTableColumns.ts, web/oss/src/components/InfiniteVirtualTable/columns/createStandardColumns.tsx, web/packages/agenta-ui/src/InfiniteVirtualTable/columns/createStandardColumns.tsx
Adds ag-table-actions-cell CSS class and stops click propagation in actions columns via onCell handlers and wrapper onClick handlers.
Selection and action cell isolation
web/oss/src/components/TestcasesTableNew/components/TestcaseSelectionCell.tsx, web/oss/src/components/TestcasesTableNew/components/TestcasesTableShell.tsx
Adds click propagation stops to selection checkboxes and wraps action dropdowns in click-guarded containers.
Legacy EvaluationRunsTable cleanup
web/oss/src/components/EvaluationRunsTablePOC/actions/navigationActions.ts, web/oss/src/components/EvaluationRunsTablePOC/components/EvaluationRunsTable/index.tsx
Removes local shouldIgnoreRowClick export and eliminates its use, consolidating click-guard logic into InfiniteVirtualTable.

Sequence Diagram

sequenceDiagram
  participant User
  participant RowClick as Row onClick Handler
  participant Guard as shouldIgnoreRowClick
  participant Navigation as Navigate Action
  User->>RowClick: click on row/cell
  RowClick->>Guard: check if target is interactive
  Guard-->>RowClick: true if button/checkbox/dropdown
  alt Guard returns true (unless disabled)
    RowClick->>RowClick: return early, no navigation
  else Guard returns false
    RowClick->>Navigation: proceed with navigation
  end
Loading

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 60.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix: Adds safeguards to the table's click handlers' clearly and specifically describes the main change: adding click handler safeguards to prevent unintended cell clicks.
Description check ✅ Passed The description explains that safeguards are added to table click handling to ignore clicks on unintended cells, which directly relates to the changeset's goal of improving click reliability.
Linked Issues check ✅ Passed The changes fully implement the requirements from issue #3254: preventing row-level clicks when users interact with action elements (buttons, dropdowns, selections), reducing accidental actions by stopping event propagation and using click guards on interactive elements.
Out of Scope Changes check ✅ Passed All changes are in-scope: they add interactive click guards, stop propagation on action cells/elements, refactor the shouldIgnoreRowClick selector logic, and add disableInteractiveClickGuard prop—all directly addressing issue #3254's requirements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/table-cell-click-issue

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dosubot dosubot Bot added bug Something isn't working Frontend labels Jun 3, 2026
@ashrafchowdury ashrafchowdury changed the base branch from release/v0.101.0 to main June 3, 2026 10:42
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jun 3, 2026
@ashrafchowdury ashrafchowdury changed the base branch from main to release/v0.101.0 June 3, 2026 10:42
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jun 3, 2026
@mmabrouk mmabrouk changed the base branch from release/v0.101.0 to main June 5, 2026 09:20
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
web/oss/src/components/InfiniteVirtualTable/components/InfiniteVirtualTableInner.tsx (1)

506-526: 💤 Low value

Consider simplifying the early-return logic for readability.

The logic at lines 516-518 is correct but subtle. When hasShortcuts is false, line 517 returns baseProps only if guardedOnClick === baseOnClick (meaning the guard didn't wrap anything), otherwise line 518 returns a new object with the wrapped onClick. This works correctly but requires careful reasoning.

Consider extracting the guard-wrapping logic or adding an explanatory comment to clarify why the equality check determines whether to return baseProps directly versus a new object.

♻️ Optional: Add clarifying comment
 
         const baseOnClick = baseProps?.onClick
         const guardedOnClick =
             !disableInteractiveClickGuard && baseOnClick
                 ? (event: React.MouseEvent<HTMLTableRowElement>) => {
                       if (shouldIgnoreRowClick(event)) return
                       baseOnClick(event)
                   }
                 : baseOnClick
 
         const hasShortcuts = shortcutProps && Object.keys(shortcutProps).length > 0
         if (!hasShortcuts) {
+            // If guard didn't wrap onClick (disabled or no onClick), reuse baseProps reference
             if (guardedOnClick === baseOnClick) return baseProps
             return {...baseProps, onClick: guardedOnClick}
         }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 65a4c44a-f495-4ea6-9a55-9df0159f97d1

📥 Commits

Reviewing files that changed from the base of the PR and between 98b8a9d and 50fb9cf.

📒 Files selected for processing (13)
  • web/oss/src/components/EvaluationRunsTablePOC/actions/navigationActions.ts
  • web/oss/src/components/EvaluationRunsTablePOC/components/EvaluationRunsTable/index.tsx
  • web/oss/src/components/InfiniteVirtualTable/columns/createStandardColumns.tsx
  • web/oss/src/components/InfiniteVirtualTable/columns/createTableColumns.ts
  • web/oss/src/components/InfiniteVirtualTable/components/InfiniteVirtualTableInner.tsx
  • web/oss/src/components/InfiniteVirtualTable/hooks/useTableManager.tsx
  • web/oss/src/components/InfiniteVirtualTable/types.ts
  • web/oss/src/components/TestcasesTableNew/components/TestcaseSelectionCell.tsx
  • web/oss/src/components/TestcasesTableNew/components/TestcasesTableShell.tsx
  • web/packages/agenta-ui/src/InfiniteVirtualTable/columns/createStandardColumns.tsx
  • web/packages/agenta-ui/src/InfiniteVirtualTable/components/InfiniteVirtualTableInner.tsx
  • web/packages/agenta-ui/src/InfiniteVirtualTable/hooks/useTableManager.tsx
  • web/packages/agenta-ui/src/InfiniteVirtualTable/types.ts
💤 Files with no reviewable changes (1)
  • web/oss/src/components/EvaluationRunsTablePOC/actions/navigationActions.ts

@ashrafchowdury ashrafchowdury requested a review from ardaerzin June 5, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Frontend size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[UI/UX] Improve click behavior in tables

5 participants