Skip to content

chore: Improving click and select actions in PZ certification BED-7356#2523

Open
LucasParraF wants to merge 5 commits intomainfrom
BED-7356-Improving-click-and-select-actions-in-PZ-certifications
Open

chore: Improving click and select actions in PZ certification BED-7356#2523
LucasParraF wants to merge 5 commits intomainfrom
BED-7356-Improving-click-and-select-actions-in-PZ-certifications

Conversation

@LucasParraF
Copy link
Contributor

@LucasParraF LucasParraF commented Mar 19, 2026

Description

While working on Certifications Table, the Data Table was managing the state of the selected rows. Now Data Table will manage the state of the of selectedRow if it is undefined adding more flexibility to the DataTable.

Motivation and Context

Resolves BED-7356

How Has This Been Tested?

Tested locally

Screenshots (optional):

Types of changes

  • Chore (a change that does not modify the application functionality)

Checklist:

Summary by CodeRabbit

  • Bug Fixes
    • Fixed DataTable row click selection behavior to properly handle cases where row selection is externally controlled versus internally managed. Clicking a row now correctly responds based on the selection context.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 19, 2026

📝 Walkthrough

Walkthrough

Modified row click selection logic in DataTable component to be conditional on selectedRow presence. When selectedRow is undefined, clicking toggles TanStack rowSelection. When provided, the component only invokes onRowClick callback without mutating internal rowSelection. Updated hook dependencies accordingly.

Changes

Cohort / File(s) Summary
Row Click Selection Logic
packages/javascript/doodle-ui/src/components/DataTable/DataTable.tsx
Modified handleRowClick to conditionally toggle rowSelection based on whether selectedRow is defined. When undefined, mutation occurs; when provided, only onRowClick callback is invoked. Updated hook dependencies to include selectedRow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: Improving click and select actions in PZ certification BED-7356' clearly relates to the main change of improving row click and selection logic in the DataTable component.
Description check ✅ Passed The description covers the main change and motivation, though testing details are minimal and motivation section lacks depth beyond the ticket reference.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 BED-7356-Improving-click-and-select-actions-in-PZ-certifications

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.

@LucasParraF LucasParraF changed the title chore: Improving click and select actions in PZ certification-BED-7356 chore: Improving click and select actions in PZ certification BED-7356 Mar 19, 2026
@LucasParraF LucasParraF self-assigned this Mar 19, 2026
@LucasParraF LucasParraF added the user interface A pull request containing changes affecting the UI code. label Mar 19, 2026
@LucasParraF LucasParraF marked this pull request as ready for review March 20, 2026 16:45
Copy link
Contributor

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/javascript/doodle-ui/src/components/DataTable/DataTable.tsx`:
- Around line 204-206: The selection-control predicate is inconsistent: one
branch checks selectedRow === undefined while the state-sync effect uses
truthy/falsy checks, which breaks when IDs are falsy (e.g., 0 or ""). Update the
state-sync effect to use the same explicit undefined check (selectedRow ===
undefined) or change both places to use a single canonical predicate (e.g.,
selectedRow === undefined for uncontrolled) so selection clearing is consistent;
locate the logic around selectedRow, the branch using
table.getState().rowSelection[row.id], and the state-sync effect and make their
checks identical.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 41149027-c339-4cf8-90f2-3797a37053f0

📥 Commits

Reviewing files that changed from the base of the PR and between 827822b and 55082e0.

📒 Files selected for processing (1)
  • packages/javascript/doodle-ui/src/components/DataTable/DataTable.tsx

Comment on lines +204 to +206
// When selectedRow is provided the parent controls selection.
if (selectedRow === undefined) {
const isAlreadySelected = table.getState().rowSelection[row.id];
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use one consistent controlled/uncontrolled predicate.

This branch uses selectedRow === undefined, but the state-sync effect uses truthy/falsy checks. That mismatch can behave differently for falsy-but-defined IDs and lead to unexpected selection clearing.

Proposed alignment
-    useEffect(() => {
-        if (!selectedRow && table.getIsSomeRowsSelected()) {
+    useEffect(() => {
+        if (selectedRow === undefined && table.getIsSomeRowsSelected()) {
             table.setRowSelection({});
         }
 
-        if (selectedRow && !table.getState().rowSelection[selectedRow]) {
+        if (selectedRow !== undefined && !table.getState().rowSelection[selectedRow]) {
             table.setRowSelection({ [selectedRow]: true });
         }
     }, [selectedRow, table]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/javascript/doodle-ui/src/components/DataTable/DataTable.tsx` around
lines 204 - 206, The selection-control predicate is inconsistent: one branch
checks selectedRow === undefined while the state-sync effect uses truthy/falsy
checks, which breaks when IDs are falsy (e.g., 0 or ""). Update the state-sync
effect to use the same explicit undefined check (selectedRow === undefined) or
change both places to use a single canonical predicate (e.g., selectedRow ===
undefined for uncontrolled) so selection clearing is consistent; locate the
logic around selectedRow, the branch using
table.getState().rowSelection[row.id], and the state-sync effect and make their
checks identical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

user interface A pull request containing changes affecting the UI code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant