-
Notifications
You must be signed in to change notification settings - Fork 290
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
base: column-virtualization
Are you sure you want to change the base?
Conversation
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", |
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.
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]": |
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.
There should not be any change in yarn.lock
package-lock.json
Outdated
@@ -0,0 +1,12685 @@ | |||
{ |
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.
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} />; |
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.
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.
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.
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
Can we group HOCs and legacy components in separate directory ? |
columnGroups: [], | ||
columnsCount: 10000, | ||
}; | ||
const cellRenderer = (props) => ( |
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.
This example should also work without any change, even when not using legacy table.
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.
Yes it will work
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.
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.
Updated the auto scroll example
src/FixedDataCellGroupFunction.js
Outdated
import cx from './vendor_upstream/stubs/cx'; | ||
|
||
function CellGroup(props) { | ||
var style = { |
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.
here or every other place, use const
instead, or let
(only if you have to modify variable later).
@@ -872,6 +872,7 @@ class FixedDataTable extends React.Component { | |||
fixedColumnsWidth={this.props.fixedColumnsWidth} | |||
fixedRightColumnsWidth={this.props.fixedRightColumnsWidth} | |||
isGroupHeader={true} | |||
shouldUseLegacyComponents={this.props.shouldUseLegacyComponents} |
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.
Declare proptype for shouldUseLegacyComponents
above.
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.
Done
@@ -30,6 +29,7 @@ class FixedDataTableContainer extends React.Component { | |||
defaultScrollbars: true, | |||
scrollbarXHeight: Scrollbar.SIZE, | |||
scrollbarYWidth: Scrollbar.SIZE, | |||
shouldUseLegacyComponents: false, |
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.
@pradeepnschrodinger should it be true or false by default ??
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.
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; |
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.
why it removed ?
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.
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} |
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.
why we need this here ?
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.
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, |
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.
we have already defined props
you don't need to use this.props here and in next lines.
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.
corrected
src/FixedDataTableCell.js
Outdated
@@ -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, |
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.
Here and every other place, use camelcase name.
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.
Done
@@ -286,13 +291,16 @@ class FixedDataTableCell extends React.Component { | |||
</FixedDataTableCellDefaultDeprecated> | |||
); | |||
} | |||
|
|||
const role = isHeaderOrFooter ? 'columnheader' : 'gridcell'; |
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.
We should not remove role
. keep it for legacy cell as it is, for new cell this could also be added in props.
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.
Done
}; | ||
|
||
if (!this.props.shouldUseLegacyComponents) { | ||
if (left === undefined) style.display = 'none'; |
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.
Please add a comment for why you do this ?
and what the reason for left going undefined here ?
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.
Is it only the case with ReorderCell ? what about regular FixedDataTableCell ?
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.
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, |
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.
Also write description for this.
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.
Done
|
||
function RowLegacy(props) { | ||
const subRowHeight = props.subRowHeight || 0; | ||
let style_wrapper = { |
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.
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.
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.
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== |
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.
Why is this change ?
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.
There is no use of this .
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
Performance before removing that div
Types of changes
Checklist: