-
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
Column Resizer Double Click Listener #617
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ class FixedDataTableCell extends React.Component { | |
* @param object event | ||
*/ | ||
onColumnResize: PropTypes.func, | ||
onColumnResizerDoubleClick: PropTypes.func, | ||
onColumnReorder: PropTypes.func, | ||
|
||
/** | ||
|
@@ -253,6 +254,7 @@ class FixedDataTableCell extends React.Component { | |
className={cx('fixedDataTableCellLayout/columnResizerContainer')} | ||
style={columnResizerStyle} | ||
onMouseDown={this._onColumnResizerMouseDown} | ||
onDoubleClick={this._onColumnResizerDoubleClick} | ||
Comment on lines
256
to
+257
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes the resize does gets called twice, right now I have handled it to ignore the event if the new column width and current column width is same. Can we do something similar in fdt only. I also think this can potentially leave the column resize blue bar to not re render if we do not trigger mouse up? The simplest way will be to leave upto the consumer to decide here similar to the way I am handling in my use case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably in this line, we can just do setState and do not call onResizeEnd if the props initialWidth and state width are equal? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I see there is a need to re render FDT with prop isColumnResizing set as false because of this line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay after taking a deeper look, I think we should introduce a COLUMN_RESIZE_END action type similar to COLUMN_RESIZE and call it on when column resize ends. This new action type can set isColumnResizing as false and also clear the columnResizing data in the state and at the same time decide to whether to call the user passed onColumnResizeEnd callback. This approach has two benefits, it takes away need to re render fdt to remove the column reisizer blue line and also will not call onColumnResizerEnd callback unnecessarily when the new and current column width are equal. Let me know your thoughts on this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This sounds good to me. We should probably leave it up to the user to decide if they want to ignore the
I got a question here: will there be any scenarios where the user doesn't want |
||
onTouchStart={ | ||
this.props.touchEnabled ? this._onColumnResizerMouseDown : null | ||
} | ||
|
@@ -338,6 +340,10 @@ class FixedDataTableCell extends React.Component { | |
} | ||
}; | ||
|
||
_onColumnResizerDoubleClick = () => { | ||
this.props.onColumnResizerDoubleClick(this.props.columnKey); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is essentially a wrapper over the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good, will add it |
||
} | ||
|
||
_onColumnReorderMouseDown = (/*object*/ event) => { | ||
this.props.onColumnReorder( | ||
this.props.columnKey, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,7 @@ class FixedDataTableRowImpl extends React.Component { | |
* @param object event | ||
*/ | ||
onColumnResize: PropTypes.func, | ||
onColumnResizerDoubleClick: PropTypes.func, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you update the jsdoc for this prop as well? |
||
|
||
isColumnReordering: PropTypes.bool, | ||
/** | ||
|
@@ -220,6 +221,7 @@ class FixedDataTableRowImpl extends React.Component { | |
columns={this.props.fixedColumns} | ||
touchEnabled={this.props.touchEnabled} | ||
onColumnResize={this.props.onColumnResize} | ||
onColumnResizerDoubleClick={this.props.onColumnResizerDoubleClick} | ||
onColumnReorder={this.props.onColumnReorder} | ||
onColumnReorderMove={this.props.onColumnReorderMove} | ||
onColumnReorderEnd={this.props.onColumnReorderEnd} | ||
|
@@ -248,6 +250,7 @@ class FixedDataTableRowImpl extends React.Component { | |
columns={this.props.fixedRightColumns} | ||
touchEnabled={this.props.touchEnabled} | ||
onColumnResize={this.props.onColumnResize} | ||
onColumnResizerDoubleClick={this.props.onColumnResizerDoubleClick} | ||
onColumnReorder={this.props.onColumnReorder} | ||
onColumnReorderMove={this.props.onColumnReorderMove} | ||
onColumnReorderEnd={this.props.onColumnReorderEnd} | ||
|
@@ -283,6 +286,7 @@ class FixedDataTableRowImpl extends React.Component { | |
columns={this.props.scrollableColumns} | ||
touchEnabled={this.props.touchEnabled} | ||
onColumnResize={this.props.onColumnResize} | ||
onColumnResizerDoubleClick={this.props.onColumnResizerDoubleClick} | ||
onColumnReorder={this.props.onColumnReorder} | ||
onColumnReorderMove={this.props.onColumnReorderMove} | ||
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.
add a new line to separate the prop types