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

Removing FixedDataTableCell div #687

Open
wants to merge 33 commits into
base: column-virtualization
Choose a base branch
from

Conversation

Archit101967
Copy link

Removing FixedDataTableCell div

Description

In this PR I have removed the div which was earlier used in FixedDataTableCell .Earlier the structure to render a cell was like FixedDataTableCell (div used for the cell container)->Type of Cell(Text cell,Date cell,Link cell,Image cell)->FixedDataTableCellDefault (div used for the text ) .But after the changes I have removed the div of FixedDataTableCell and the structure will be like FixedDataTableCell (no div used)->Type of Cell(Text cell,Date cell,Link cell,Image cell)->FixedDataTableCellDefault (div used for styling) .So I have provided all the styling and classnames to the FixedDataTableCell div only .And we have to also correct the resize and reorder cell rendering because their styling and functionalities will also get effected .

Motivation and Context

For optimising the performance of fixed-data-table-2

How Has This Been Tested?

Tested using our local examples

Screenshots (if appropriate):

Performance after removing that div
Screenshot 2023-06-28 at 12 25 58 PM

Performance before removing that div
Screenshot 2023-06-28 at 12 26 47 PM

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.

package.json Outdated
@@ -11,6 +11,7 @@
"@reduxjs/toolkit": "^1.5.1",
"lodash": "^4.17.4",
"prop-types": "^15.7.2",
"react-fps": "^1.0.6",
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is only supposed to be used for our internal testing, we should remove this.
Also there should not be any change in yarn.lock and package-lock.json should not exist at all.

yarn.lock Outdated
@@ -1033,26 +1033,10 @@
"@jridgewell/resolve-uri" "^3.0.3"
"@jridgewell/sourcemap-codec" "^1.4.10"

"@nodelib/[email protected]":
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should not be any change in yarn.lock

@@ -0,0 +1,12685 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Delete this file as well, I think it's comes because you might have used npm to install some package but we should use yarn to add any package.

{children}
</div>
);
return <CellDefaultComponent {...this.props} />;
Copy link
Collaborator

@AmanGupta2708 AmanGupta2708 Jun 28, 2023

Choose a reason for hiding this comment

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

FixedDataTableCellDefault, aka DataCell, is essentially a type of cell that clients can utilize as a cell renderer. Clients have the flexibility to use any valid element or function as a cell renderer, and we have no control over the styles they apply to them.

we want to solely apply the necessary styles to the content within the FixedDataTableCell. That content is what the client passes, which can be either a DataCell or any other customized cell, or a function that returns a cell, or simply raw data.

Copy link
Author

Choose a reason for hiding this comment

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

We are passing default styles and default classNames as props from FixedDataTableCell which can be used by client if he don't want to provide any styles to it .And if a client wants to add his own styles he can do that also

@AmanGupta2708
Copy link
Collaborator

Can we group HOCs and legacy components in separate directory ?

columnGroups: [],
columnsCount: 10000,
};
const cellRenderer = (props) => (
Copy link
Collaborator

Choose a reason for hiding this comment

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

This example should also work without any change, even when not using legacy table.

Copy link
Author

Choose a reason for hiding this comment

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

Yes it will work

Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't seems to be working correctly for me.
Screenshot 2023-06-29 at 12 51 32 AM

Note that cell-render could be anything i.e DataCell, TextCell, LinkCell, ImageCell or any customized cell or raw data, and this example should render same table as before for each case.

Copy link
Author

Choose a reason for hiding this comment

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

Updated the auto scroll example

import cx from './vendor_upstream/stubs/cx';

function CellGroup(props) {
var style = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

here or every other place, use const instead, or let (only if you have to modify variable later).

src/FixedDataCellGroupLegacyFunction.js Outdated Show resolved Hide resolved
@@ -872,6 +872,7 @@ class FixedDataTable extends React.Component {
fixedColumnsWidth={this.props.fixedColumnsWidth}
fixedRightColumnsWidth={this.props.fixedRightColumnsWidth}
isGroupHeader={true}
shouldUseLegacyComponents={this.props.shouldUseLegacyComponents}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Declare proptype for shouldUseLegacyComponents above.

Copy link
Author

Choose a reason for hiding this comment

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

Done

@@ -30,6 +29,7 @@ class FixedDataTableContainer extends React.Component {
defaultScrollbars: true,
scrollbarXHeight: Scrollbar.SIZE,
scrollbarYWidth: Scrollbar.SIZE,
shouldUseLegacyComponents: false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

@pradeepnschrodinger should it be true or false by default ??

Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be false by default to encourage users to NOT rely on legacy components.

@@ -59,7 +59,6 @@

.fixedDataTableCellLayout/columnResizerContainer {
position: absolute;
right: 0px;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why it removed ?

Copy link
Author

Choose a reason for hiding this comment

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

Because earlier we were placing the resizer knob from the right('0px') relative to the div we removed .So this knob was appearing at the end of that cell div .But now as we removed that div so I am adjusting the position of the knob from the left according to the width of each cell .The adjusting of position code is in ResizerKnobFunction where I am also providing left in the resizerKnobStyle

@@ -64,12 +62,15 @@ class ResizeCell extends React.PureComponent {
height={this.props.height}
resizerLineHeight={this.context.tableHeight}
onColumnResizeEnd={this.props.onColumnResizeEnd}
onColumnReorderEnd={this.props.onColumnReorderEnd}
Copy link
Collaborator

Choose a reason for hiding this comment

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

why we need this here ?

Copy link
Author

Choose a reason for hiding this comment

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

To correct the functionality of resize and reorder cell combined example .Because in that example we are firstly rendering the Reorder Plugin and than it's child which is Resize plugin .So there is one more div which is being added which is the div of reorder cell and we are providing the styling in this div only which is also adjusting the cell from left .So, if our resize cell is being rendered after reorder cell than we have to adjust the left of resizer knob differently .The code of styling this resizer knob is in ResizerKnobFunction.js

touchEnabled,
cellGroupType,
onColumnReorderStart,
...props
} = this.props;

let style = {
height: props.height,
width: props.width - BORDER_WIDTH,
height: this.props.height,
Copy link
Collaborator

Choose a reason for hiding this comment

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

we have already defined props you don't need to use this.props here and in next lines.

Copy link
Author

Choose a reason for hiding this comment

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

corrected

@@ -223,6 +225,9 @@ class FixedDataTableCell extends React.Component {
height: this.props.height,
width: this.props.width,
left: this.props.left,
shouldUseLegacyComponents: this.props.shouldUseLegacyComponents,
style_default: style,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here and every other place, use camelcase name.

Copy link
Author

Choose a reason for hiding this comment

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

Done

@@ -286,13 +291,16 @@ class FixedDataTableCell extends React.Component {
</FixedDataTableCellDefaultDeprecated>
);
}

const role = isHeaderOrFooter ? 'columnheader' : 'gridcell';
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should not remove role. keep it for legacy cell as it is, for new cell this could also be added in props.

Copy link
Author

Choose a reason for hiding this comment

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

Done

};

if (!this.props.shouldUseLegacyComponents) {
if (left === undefined) style.display = 'none';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add a comment for why you do this ?
and what the reason for left going undefined here ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it only the case with ReorderCell ? what about regular FixedDataTableCell ?

Copy link
Author

@Archit101967 Archit101967 Jul 4, 2023

Choose a reason for hiding this comment

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

This was occuring only in reorder cell only because earlier I was setting left of style here(reorder cell) only but I can directly use the styleDefault in which I will fix the left in FixedDataTableCell and then pass the whole styleDefault as prop to reorder cell .So left will be set according to the rendering of FixedDataTableCell component .I corrected this thing in the new commit in other way and dropped this hacky way .

@@ -524,6 +524,8 @@ class FixedDataTable extends React.Component {
* ```
*/
rowAttributesGetter: PropTypes.func,

shouldUseLegacyComponents: PropTypes.bool,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also write description for this.

Copy link
Author

Choose a reason for hiding this comment

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

Done


function RowLegacy(props) {
const subRowHeight = props.subRowHeight || 0;
let style_wrapper = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can change the properties of const object as well, use const wherever you use let just because you later want to modify some of its properties.

Copy link
Author

Choose a reason for hiding this comment

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

Done

@@ -8418,4 +8418,4 @@ yargs@^11.0.0:
yocto-queue@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this change ?

Copy link
Author

Choose a reason for hiding this comment

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

There is no use of this .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants