Skip to content
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

Reduce dom levels in the default cell renderer #556

Closed

Conversation

pradeepnschrodinger
Copy link
Collaborator

@pradeepnschrodinger pradeepnschrodinger commented Sep 8, 2020

Description

Minimize dom components in the default cell renderer, as part of #396.
See LD side changes required at SB-18854

Motivation and Context

Increase performance by reducing 3 dom levels per cell.

How Has This Been Tested?

Tested on our examples and also on LD.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

Copy link
Collaborator Author

@pradeepnschrodinger pradeepnschrodinger left a comment

Choose a reason for hiding this comment

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

I don't think the renderer changes shown in this review can be deemed as 'non-breaking.'
The new renderer has slightly different css, but the biggest change would be the change in nesting of elements (or lack of).

@wcjordan , how about we mark this cell renderer as deprecated for now? We could then provide the newer cell renderer as part of the API so that users can gradually migrate to it.

@@ -87,26 +87,14 @@ class FixedDataTableCellDefault extends React.Component {
<div
{...props}
className={joinClasses(
cx('fixedDataTableCellLayout/wrap1'),
cx('public/fixedDataTableCell/wrap1'),
cx('fixedDataTableCellLayout/wrap'),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We condense all the 3 wrapper levels into the top level div.
Also I'm pulling up the cellContent class name.

@@ -29,10 +29,9 @@
background-color: #0284ff;
}
.public/fixedDataTableCell/hasReorderHandle .public/fixedDataTableCell/cellContent {
margin-left: 12px;
padding-left: 20px;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Margin was added here so as to leave some space if the reorder handle exists.
But now, the only wrapper element has display set to table-cell, and such elements are unable to have margin.
So we'll just add these to padding instead. It should have the same effect for most use cases.

But if the user wants to add margin, he can either

  • change the display property
  • change padding
  • just make a new wrapper element

@wcjordan
Copy link
Member

wcjordan commented Sep 9, 2020

I like that idea. Let's deprecate these and remove in v2. We can provide the new one and switch all the examples over to use the new one.

Copy link
Member

@wcjordan wcjordan left a comment

Choose a reason for hiding this comment

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

lgtm, but I agree it would be better to deprecate this and provide an alternative. We can switch all the examples to use the alternative. In v2 we can delete this older cell.

Copy link
Collaborator Author

@pradeepnschrodinger pradeepnschrodinger left a comment

Choose a reason for hiding this comment

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

I kept the old default cell renderer and renamed it to FixedDataTableCellDefaultDeprecated

@@ -0,0 +1,118 @@
/**
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This file is just the old FixedDataTableCellDefault.
There's no change besides a comment explaining this component is deprecated.

Comment on lines +21 to +22
* NOTE (pradeep): This component is deprecated since it uses a lot of wrapper DIV nodes for styling/layout.
* The replacement is src/FixedDataTableCell.js which uses a single wrapper to achieve the same table cell layout.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The only change in the file.

import Column from 'FixedDataTableColumn';
import ColumnGroup from 'FixedDataTableColumnGroup';

const version = '1.1.0';

export {
Cell,
CellDeprecated,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Users who still wanna use the old cell will need to export CellDeprecated

Copy link
Collaborator

Choose a reason for hiding this comment

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

This would still be a breaking change in terms of API right. How about naming the new cell something like DataCell to avoid name conflict? CC: @wcjordan

Copy link
Member

Choose a reason for hiding this comment

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

I'm all for not breaking the API until a major update. DataCell sounds fine to me.

@pradeepnschrodinger
Copy link
Collaborator Author

As discussed above, to not break the API, we'll rename the newer cell component to DataCell.
I also added changes to update all examples to use DataCell.

@somavara, @wcjordan , could you take a look again and give another sign off?

Copy link
Member

@wcjordan wcjordan left a comment

Choose a reason for hiding this comment

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

New updates lgtm. Thanks for updating all the examples!

pradeepnschrodinger added a commit that referenced this pull request Dec 2, 2020
Introduced new cell renderer `DataCell`, which is a leaner implementation of the default `Cell` renderer.
@pradeepnschrodinger
Copy link
Collaborator Author

Merged to master.

@pradeepnschrodinger pradeepnschrodinger deleted the SS-27499-ReduceDefaultCellRenderer branch December 2, 2020 05:49
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.

3 participants