-
Notifications
You must be signed in to change notification settings - Fork 289
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
Expose cell visibility information to cell renderers #658
Conversation
@@ -289,6 +305,7 @@ class FixedDataTableCell extends React.Component { | |||
columnKey, | |||
height, | |||
width, | |||
isVisible, |
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 exposes isVisible
to the cell renderers.
@@ -183,6 +186,7 @@ class FixedDataTableCellGroupImpl extends React.Component { | |||
columnGroupWidth={columnGroupWidth} | |||
pureRendering={pureRendering} | |||
isRTL={this.props.isRTL} | |||
isVisible={this.props.isVisible && isHorizontallyVisible} |
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.
At this component level, props.isVisible
refers to whether the cell group is vertically visible.
This combined with isHorizontallyVisible
determines whether the individual cell is within the viewport.
// if row is not visible then no need to render it | ||
// change in visibility is handled by the parent | ||
// if row's visibility has changed, then update it | ||
if (this.props.visible !== nextProps.visible) { |
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.
Rerender the component when visibility changes, similar to the usage here.
if ( | ||
nextProps.isScrolling && | ||
this.props.rowIndex === nextProps.rowIndex && | ||
this.props.isVisible === nextProps.isVisible |
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.
Ensure cell is rerendered whenever visibility changes.
Released with v.1.2.13 |
Typo came through #658
@Tanner-MS , I fixed the PropTypes typo through bc27879, which is available on v1.2.15. |
Description
Not all cells rendered by FDT are visible to the user.
eg: Cells for columns outside the viewport will be rendered if
allowCellsRecycling
column prop is turned off.Similarly, if the user has specified a positive value for
bufferRowCount
, then FDT prerenders a given count of rows before/after the viewport.I'm adding a new cell prop
isVisible
, which can be used to figure out if the rendered cell is visible to the user.Motivation and Context
Fixes #650, where the user wanted to run some side effects for a cell based on whether it's visible or not.
How Has This Been Tested?
Tested using our local examples.
Types of changes
Checklist: