-
-
Notifications
You must be signed in to change notification settings - Fork 139
feat: add enabledRowHighlight to highlight the selected row #535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new boolean property (enabledRowHighlight) for the Table component to automatically highlight the selected row. The key changes include adding the enabledRowHighlight prop and corresponding logic in Table.tsx, updating the row click handler to toggle highlighting, and adding documentation and an example for the new feature.
Reviewed Changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Table.tsx | Added the enabledRowHighlight prop and corresponding row highlight logic in the Table component |
| docs/index.tsx | Added a new example entry for enabled row highlighting |
| docs/examples/EnabledRowHighlightTable.md | Provided a usage example of the new row highlighting feature |
Files not reviewed (2)
- src/less/table.less: Language not supported
- src/less/variables.less: Language not supported
|
Hi @nandobutzke, If your goal is simply to highlight the selected row, you can easily achieve this using <Table
rowClassName={rowData => {
if (rowData?.id === selectedRowId) {
return 'selected-row';
}
}}
onRowClick={data => {
setSelectedRowId(data.id);
}}
>
...
</Table>Add CSS: .rs-table-row.selected-row .rs-table-cell {
background: red !important;
} |
Thanks for the reply, @simonguo! I recently used a similar approach. I'll be around in case you need any help, whether in this repository or another one from React Suite 🚀 |
Co-authored-by: Copilot <[email protected]>
|
Thank you @nandobutzke |
Hello everyone,
Recently, while working on a project that involved the Table component alongside another component to visualize selected row data, I noticed the need for an easier way to highlight the selected row.
As a learning exercise, I implemented a new boolean property named enabledRowHighlight, which natively enables row highlighting. When this property is set on the Table component, it will automatically apply a background color to the selected row, improving visibility without additional manual handling.
Feedback and suggestions are very welcome. Let me know what you think!