-
Notifications
You must be signed in to change notification settings - Fork 104
feat(AnalyticalTable): introduce autoResize column feature (#3196) #5758
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
Conversation
Pull Request Test Coverage Report for Build 9203673320Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
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.
Hi @Papa-Santo
Thanks a lot for your contribution! :)
Below you can find the first findings of my review, I will most probably continue it at the start of next week:
-
Since expandable rows are rendering a button/icon (depending on theme) inside a cell,
autoResizeable
isn't working properly for them. Please either exclude grouped tables, tree tables (isTreeTable: true
) and tables with expandable subcomponents (renderRowSubComponent
withsubComponentsBehavior
Expandable
orIncludeHeightExpandable
), or include the icon/button and the indentation in the calculation. If you decide to exclude these modes, please add a note about it to the property. -
Maybe you can reuse some logic of the useDynamicColumnWidths hook. (E.g. stringToPx) - This is not a requirement, using
canvas
is fine for me as well, I just wanted to point out that such a thing exists.
A functionality by which the cell width gets auto adjusted when we double click the data-resizer columns. Implemented for text.
…useDynamicColumnWidths. Detecting expandable rows and adjusting for the icon/button space. Removed support for isTreeTable and tables with strings in the groupBy array
bfe826f
to
3142f0f
Compare
Hi @Papa-Santo I really like the approach with a plugin hook. 👍 I plan to push the commit/s today. |
Terrific. Thank you! |
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.
Hi @Papa-Santo
I've pushed my changes. I've also added some comments to explain why I changed some things.
I didn't have time to test these changes carefully, but at least all test cases are green :D
If you find any bugs or would do something different, please feel free to raise your concerns or adjust it directly.
packages/main/src/components/AnalyticalTable/ColumnHeader/ColumnHeaderContainer.tsx
Show resolved
Hide resolved
packages/main/src/components/AnalyticalTable/TableBody/VirtualTableBody.tsx
Outdated
Show resolved
Hide resolved
packages/main/src/components/AnalyticalTable/defaults/Column/Cell.tsx
Outdated
Show resolved
Hide resolved
packages/main/src/components/AnalyticalTable/hooks/useAutoResize.tsx
Outdated
Show resolved
Hide resolved
packages/main/src/components/AnalyticalTable/hooks/useAutoResize.tsx
Outdated
Show resolved
Hide resolved
packages/main/src/components/AnalyticalTable/hooks/useAutoResize.tsx
Outdated
Show resolved
Hide resolved
packages/main/src/components/AnalyticalTable/hooks/useAutoResize.tsx
Outdated
Show resolved
Hide resolved
packages/main/src/components/AnalyticalTable/hooks/useStyling.ts
Outdated
Show resolved
Hide resolved
This is a big improvement. I like how you were able to encapsulate everything in the hook. I was wanting to accomplish that same thing. I only have a concern about the new measurements. Some of it might be due to my lack of understanding of isRtl. Here is a bug that came up after these changes (See the behavior of resizing age): Bug-Age.mp4I have a fix that changes code inside of getMeasureMax and allows us to measure other types of elements as well: Bug-Fix-Extra-Functionality.mp4The code is pushed in. |
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.
Hi @Papa-Santo
thanks again for your input!
I think measuring children
is the right approach here, so great idea :)
I've refactored the measure function again, so we don't have to rely on styles anymore (except for padding). With this approach no additional logic is necessary to support RTL reading direction. Also, custom content is now partially supported.
querySelectors
don't start at thedocument
level now, but on "tabel-level"- The largest cell is now retrieved by checking text
span
and only then each child of the cell is measured. For tree tables this would lead to wrong values depending on nesting levels, so if the cell containing the expand/collapse button is auto-resized each child of each visible cell is measured. - The description and type of the public event were adjusted.
Looking forward to your feedback :)
I read through the code and tested for a bit now. It's working great! This works for all the normal use cases I tried and it is more efficient. It is important to add what you added to the description. I did some ecotic table setups and came across a small regression.
With the current measuring: Conditional-Rendering-Unsupported.mp4With the measurements before changes: Conditional-Rendering-Support.mp4I really like this part of the solution:
If you agree that this solutions efficiency is better than the more costly solution which adds support for custom cells with conditional rendering, this seems ready. Thanks again! |
Sorry, I didn't go into enough details for custom cell support. I think in the initial implementation we don't need to support that behavior, since we can't support every possible content passed to a cell anyway. If the need arises to also support basic custom content, we can then check to add a way to allow configuring the measuring method.
Yup, for the time being I'd like to keep this functionality :) I'll ask a colleague to have a quick look at this PR, and if he doesn't find anything we're good to merge. Thank you! |
🎉 This PR is included in version v1.29.0 🎉 The release is available on v1.29.0 Your semantic-release bot 📦🚀 |
A functionality by which the cell width gets auto adjusted when we double click the data-resizer columns. Implemented for text.
Thank you for your contribution! 👏
To get it merged faster, kindly review the checklist below:
Pull Request Checklist