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
Implement #28 #35
Implement #28 #35
Conversation
Thank you for the PR! I'll have an in-depth look at it over the next few days. Meanwhile, just from a quick view, I have a few comments: Trying to run the code (again, without really reviewing it) shows the following console warning: Right now, if I'm adding this on the complex usage example: // ...
expandedRow={{
item: ({ firstName }) => <Box sx={{ border: '1px solid red' }}>{firstName}</Box>,
}}
// ... ...here's is what I get: I think the idea of using a There are some other things that should be taken into account, i.e.:
Please allow me a few days to have a better look at it. |
If I install the Prettier and ESLint VSCode extensions will that work? Or are there more steps I need to take? I've never worked with a linter or prettier before. I'll give WSL2 a shot as well!
Ah I see. I think at first glance I like the first solution more, but I'll play around with it and see if any other ideas come to mind.
I think it's reasonable if the
That was my intention, but I guess I forgot to add that in. I'll try and get to that today.
Sounds good. I'll see if I can get it to run lol. |
width works correctly now toggles correctly on click red border still unsolved
I fixed the mentioned issues. I wasn't able to figure out how to get rid of the red border around the expandedRow though... I'm still learning how to debug classes created by createStyles. |
Didn't mean to mark this as |
I glanced at the code again and realized that the red border was added in by the test code I copied from your comment. Whoops. I believe I've fixed all of the bugs, and this is ready for review. |
Sorry for not being able to reply sooner. Yes, I've added the red border in my comment so we can easily see what's boing rendered. It's a common quick & dirty practice :-) |
Looking at it now. Thanks again for your effort! |
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.
Might have to refactor a few things after merging to keep coding style consistent, I hope you won't mind.
I'll also test all the available examples to see how this affects the already existent features. One thing I've discovered so far: all rows have cursor: pointer
now, and they shouldn't. It's probably due to the fact that each DataTableRow
unconditionally receives an onClick
handler, and it always sets this class: [classes.withClickHandler]: onClick
. I'll see what I cand do about it.
I'll also add an example to illustrate the new functionality.
@@ -187,7 +188,7 @@ export default function DataTable<T>({ | |||
}; | |||
|
|||
/** | |||
* React hooks linting rule would reccomend to also include the `useDobouncedState` setters | |||
* React hooks linting rule would recommend to also include the `useDobouncedState` setters |
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.
Nice catch ;-)
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.
Y'know, I just noticed that it says useDobouncedState
instead of useDebouncedState
. Didn't catch that one ;-)
Please allow me a an hour or so to add an example and see if any refactoring is needed before publishing a new version on |
Quick tip: I was tempted to use expandedRow: {
padding: '0 !important'
} So I'll change it to: expandedRow: {
'&&': {
padding: 0
}
}
See more info here: https://stackoverflow.com/questions/62660480/is-there-a-way-to-increase-specificity-by-adding-the-element-with-emotion |
A couple of regressions I'm noticing now, besides the
|
Can you share a picture of what happens when the table is |
Thanks for the tip! I knew |
Also, I'm gonna have to refactor this: const { expandRowOn = 'click', expandMultiple = false, expandFirst, collapseProps } = expandedRow ?? {}; ...because it triggers a re-render on every row click, regardless of whether you're providing an |
All "normal" rows appear dark: The "expanded" rows are light: It happens due to the way striped rows are styled in the underlying Mantine table, with |
Ah that's not good... I'm still getting familiar with all of the things that can trigger unnecessary re-renders. Thanks for taking the time to go through my less-than-perfect code :D |
Ahh that makes sense. I wonder if, instead of having the expanded rows in their own |
All code is perfectible, none is perfect :-) Mine is always far from perfect :-). Of course I'm taking the time; you were generous enough and willing to commit your own time to the project. If you'll look through the comments in Mantine's issues & discussions, you'll see that many people are asking for features, but so few understand that open-source is not just about using other people's work, but also about contributing. Thank you for putting time into this! |
Wouldn't that result in invalid HTML? |
I did a bit of refactoring (hope you won't mind); mostly changed So, let's continue working on the next branch. Pull it, and if you'll run it locally you can test the feature at http://localhost:3000/examples/expanding-rows Example page text is in |
🤷 I have no idea. I only learned how HTML tables worked last week 😆 Almost all of my prior experience has been pure JS/TS.
I don't mind at all 😆 My implementation was a little bit clunky for sure.
Sounds good. It might be a day or two before I have time though. |
No problem, I'm a bit up-to-my ears in other stuff too. It will have to wait a few days anyway, because I still couldn't understand where the unnecessary re-renders are coming from. |
I see there is a |
Oh is |
Here is my first stab at implementing the functionality discussed in #28. Allows the consumer to pass in any custom component. That custom component is passed to the new
DataTableRowParent
wrappers around eachDataTableRow
and will be rendered beneath the row ifisExpanded
is set.isExpanded
is calculated in theDataTable
itself.The custom component is wrapped in a Collapse component from
@mantine/core
. The expansion animation behaviour can be customized via theexpandedRow.collapseProps
property.Please let me know what you think. Should there be more features added? Fewer?
Also please note that this is untested and unlinted. The
build
anddev
scripts wouldn't work for me - I suspect that may be because I'm on Windows, but I haven't had much of a chance yet to troubleshoot.