Skip to content

feat: rowclick disable functionality added#584

Merged
ssolanki-p44 merged 4 commits intomainfrom
ACTINSTS-2536-add-row-click-disable
May 6, 2025
Merged

feat: rowclick disable functionality added#584
ssolanki-p44 merged 4 commits intomainfrom
ACTINSTS-2536-add-row-click-disable

Conversation

@ssolanki-p44
Copy link
Contributor

@ssolanki-p44 ssolanki-p44 commented May 5, 2025

Closes #

📝 Description

Add a brief description

Added row click disable functionality based on a condition, style applied only if onRowClick is passed and entire row is clickable

Screenshots

Please provide screenshots for any visual changes

Screenshot 2025-05-05 at 9 50 12 PM

Merge checklist

  • Added/updated tests
  • Added changeset

@ssolanki-p44 ssolanki-p44 requested a review from a team as a code owner May 5, 2025 16:20
@changeset-bot
Copy link

changeset-bot bot commented May 5, 2025

🦋 Changeset detected

Latest commit: fcd30d5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@project44-manifest/react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented May 5, 2025

Summary by CodeRabbit

  • New Features

    • Added the ability to enable or disable row click functionality in the DataTable component, either globally or conditionally per row.
    • Introduced a new story demonstrating conditional row click disabling.
  • Bug Fixes

    • Corrected the parameter order in the row click handler for more intuitive usage.
  • Documentation

    • Updated DataTable documentation to reflect the new row click control and revised handler signature.
      """

Walkthrough

The changes introduce a new prop, enableRowClick, to the DataTable component in the React package. This prop allows row click events to be conditionally enabled or disabled, either globally (boolean) or per row (function). The onRowClick handler's signature is updated to accept the row object first and the row ID second. Documentation, types, implementation, and stories are updated to reflect these changes. A new story demonstrates disabling row clicks for specific rows.

Changes

Files/Paths Change Summary
.changeset/sixty-ravens-sip.md Added changeset documenting the new enableRowClick feature for the DataTable component.
packages/react/docs.json Updated DataTable documentation to include enableRowClick prop and corrected onRowClick signature.
packages/react/src/components/DataTable/DataTable.types.ts Added enableRowClick prop to DataTableProps and updated onRowClick signature.
packages/react/src/components/DataTable/DataTable.tsx Passed new enableRowClick prop with default value false to DataTable and down to table options.
packages/react/src/components/DataTable/components/DataTableBody/DataTableBody.tsx Modified row rendering logic to conditionally enable row clicks based on enableRowClick.
packages/react/src/components/DataTable/story/DataTable.stories.tsx Updated RowClick story for new handler signature; added story for disabling row clicks on specific rows.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DataTable
    participant DataTableBody

    User->>DataTable: Renders with enableRowClick (bool or fn) and onRowClick
    DataTable->>DataTableBody: Passes enableRowClick and onRowClick
    DataTableBody->>User: Renders rows
    User->>DataTableBody: Clicks on a row
    DataTableBody->>DataTableBody: Checks enableRowClick (bool or fn) for row
    alt Row click enabled
        DataTableBody->>DataTable: Calls onRowClick(row, rowId)
    else Row click disabled
        DataTableBody-->>User: No action
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Add row click functionality in DataTable (ACTINSTS-2536)

Poem

In the garden of tables, a change hops in,
Rows now choose if they’ll let you begin—
Click me or not, it’s up to each row,
Some say yes, some politely say no.
With stories and code, the features expand,
🐇 Cheers to control at the tip of your hand!
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fcd30d5 and 5bc3791.

📒 Files selected for processing (2)
  • packages/react/src/components/DataTable/DataTable.tsx (2 hunks)
  • packages/react/src/components/DataTable/DataTable.types.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/react/src/components/DataTable/DataTable.tsx
  • packages/react/src/components/DataTable/DataTable.types.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Validate
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 2

🧹 Nitpick comments (2)
packages/react/src/components/DataTable/story/DataTable.stories.tsx (2)

370-422: Great demonstration of the new enableRowClick functionality

This new story effectively demonstrates the conditional row click functionality by disabling clicks on a specific row (ID '3'). The implementation is clear and includes helpful context for users to understand which row will have clicking disabled.

One minor suggestion - consider adding a visual indicator (such as a different cursor or styling) for the disabled row to make it more obvious to users which row has clicking disabled.

  css={{
    '.manifest-table__row:hover': {
      backgroundColor: '$background-hover',
+   },
+   '.manifest-table__row[data-disabled-click="true"]': {
+     cursor: 'default',
+     opacity: 0.7
    },
  }}

416-416: Consider adding a comment explaining the condition

The condition rowId !== '3' works for the example, but a brief comment would help readers understand the intent more quickly.

-        enableRowClick={(row, rowId) => rowId !== '3'}
+        // Disable row click for row with ID '3' to demonstrate conditional click functionality
+        enableRowClick={(row, rowId) => rowId !== '3'}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b31fe4 and bf0a69c.

📒 Files selected for processing (6)
  • .changeset/sixty-ravens-sip.md (1 hunks)
  • packages/react/docs.json (2 hunks)
  • packages/react/src/components/DataTable/DataTable.tsx (2 hunks)
  • packages/react/src/components/DataTable/DataTable.types.ts (2 hunks)
  • packages/react/src/components/DataTable/components/DataTableBody/DataTableBody.tsx (1 hunks)
  • packages/react/src/components/DataTable/story/DataTable.stories.tsx (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/react/src/components/DataTable/components/DataTableBody/DataTableBody.tsx (1)
packages/react/src/components/DataTable/components/DataTableCell/DataTableCell.tsx (1)
  • DataTableCell (9-40)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Validate
  • GitHub Check: Changeset
🔇 Additional comments (9)
.changeset/sixty-ravens-sip.md (1)

5-5: LGTM! Changeset description accurately captures the feature.

The changeset message clearly describes the new functionality being added.

packages/react/src/components/DataTable/DataTable.tsx (2)

66-66: LGTM! New prop added with sensible default.

The enableRowClick prop is added with a default value of true, which maintains backward compatibility with the existing behavior where rows are clickable by default.


162-162: LGTM! Option added to table configuration.

The enableRowClick prop is correctly passed to the table options, making it available to the DataTableBody component.

packages/react/docs.json (1)

498-503: LGTM! Documentation for new property is clear and accurate.

The new enableRowClick property is properly documented with its type and purpose.

packages/react/src/components/DataTable/components/DataTableBody/DataTableBody.tsx (2)

10-14: LGTM! Row clickability logic is well-implemented.

The implementation correctly extracts the options from the table configuration and handles both boolean and function forms of the enableRowClick prop.


16-32: LGTM! Row click handling and styling is correctly implemented.

The code:

  1. Adds pointer cursor styling only when a row is clickable and onRowClick is defined
  2. Invokes onRowClick only when the row is clickable
  3. Uses the updated parameter order (row.original, row.id)

This implementation correctly enables/disables row click functionality based on the condition.

packages/react/src/components/DataTable/DataTable.types.ts (1)

143-148: Good addition of the enableRowClick prop

The new enableRowClick prop is well designed, providing flexibility by accepting either a boolean for global control or a function for per-row conditional enabling. The documentation is clear and the implementation follows the existing pattern of other enable/disable props in the component.

packages/react/src/components/DataTable/story/DataTable.stories.tsx (2)

341-347: Updated state handling for the new onRowClick signature

The state variables and handler function have been correctly updated to match the new onRowClick signature, storing both the row object and row ID separately. This is a good pattern that makes it clear what information is being tracked.


352-354: Improved display of selected row information

The display now clearly shows both the selected row index and the serialized row data, which provides better context for users of the story.

onRowSelectionChange,
onSortingChange,
onScroll,
enableRowClick = true,
Copy link
Contributor

Choose a reason for hiding this comment

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

@ssolanki-p44 Do we need default value as true ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

vivek-p44
vivek-p44 previously approved these changes May 6, 2025
Copy link
Contributor

@vivek-p44 vivek-p44 left a comment

Choose a reason for hiding this comment

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

LGTM

@ssolanki-p44 ssolanki-p44 merged commit 32be0b2 into main May 6, 2025
5 checks passed
@ssolanki-p44 ssolanki-p44 deleted the ACTINSTS-2536-add-row-click-disable branch May 6, 2025 14:29
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.

4 participants