Fix: Adds safeguards to the table's click handlers#4540
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughSummary by CodeRabbitRelease Notes
WalkthroughThis 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. ChangesTable Click Behavior Improvements
Sequence DiagramsequenceDiagram
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
🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
79b9d93 to
8af8fc5
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
web/oss/src/components/InfiniteVirtualTable/components/InfiniteVirtualTableInner.tsx (1)
506-526: 💤 Low valueConsider simplifying the early-return logic for readability.
The logic at lines 516-518 is correct but subtle. When
hasShortcutsis false, line 517 returnsbasePropsonly ifguardedOnClick === baseOnClick(meaning the guard didn't wrap anything), otherwise line 518 returns a new object with the wrappedonClick. 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
basePropsdirectly 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
📒 Files selected for processing (13)
web/oss/src/components/EvaluationRunsTablePOC/actions/navigationActions.tsweb/oss/src/components/EvaluationRunsTablePOC/components/EvaluationRunsTable/index.tsxweb/oss/src/components/InfiniteVirtualTable/columns/createStandardColumns.tsxweb/oss/src/components/InfiniteVirtualTable/columns/createTableColumns.tsweb/oss/src/components/InfiniteVirtualTable/components/InfiniteVirtualTableInner.tsxweb/oss/src/components/InfiniteVirtualTable/hooks/useTableManager.tsxweb/oss/src/components/InfiniteVirtualTable/types.tsweb/oss/src/components/TestcasesTableNew/components/TestcaseSelectionCell.tsxweb/oss/src/components/TestcasesTableNew/components/TestcasesTableShell.tsxweb/packages/agenta-ui/src/InfiniteVirtualTable/columns/createStandardColumns.tsxweb/packages/agenta-ui/src/InfiniteVirtualTable/components/InfiniteVirtualTableInner.tsxweb/packages/agenta-ui/src/InfiniteVirtualTable/hooks/useTableManager.tsxweb/packages/agenta-ui/src/InfiniteVirtualTable/types.ts
💤 Files with no reviewable changes (1)
- web/oss/src/components/EvaluationRunsTablePOC/actions/navigationActions.ts
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