DetailsList: adding an optional column re-ordering feature#4857
DetailsList: adding an optional column re-ordering feature#4857betrue-final-final merged 20 commits intomicrosoft:masterfrom
Conversation
c5b9bb6 to
61af28d
Compare
|
This would definitely be a Please add tests for the new DetailsColumn component and consider making test cases for DetailsHeader and/or DetailsList components to exercise the new functionality. This will help ensure nobody breaks the functionality you've added. 😃 |
| frozenColumnCount?: number; | ||
|
|
||
| /** Callback to handle the column reorder | ||
| * draggaedIndex is the source column index, that need to be placed in targetIndex |
| dragDropEvents={ this._getDragDropEvents() } | ||
| /> | ||
| </MarqueeSelection> | ||
| {/* <MarqueeSelection selection={ this._selection }> */ } |
There was a problem hiding this comment.
Why was MarqueeSelection removed? Is there a reason to leave it the codebase commented out?
There was a problem hiding this comment.
Reverted these changes in latest commit, after resolving marquee selection issue
e40bf24 to
e5fcc6a
Compare
|
@amitdh is added to the review. #Closed |
| onDrop?: (item?: any, event?: DragEvent) => void; | ||
| onDragStart?: (item?: any, itemIndex?: number, selectedItems?: any[], event?: MouseEvent) => void; | ||
| onDragEnd?: (item?: any, event?: DragEvent) => void; | ||
| onDragOver?: (item?: any, event?: DragEvent) => void; |
There was a problem hiding this comment.
onDragOver?: (item?: any, event?: DragEvent) => void; [](start = 2, length = 53)
Do we have to expose this in IDragDropEvents interface? #Closed
There was a problem hiding this comment.
Yes, as this is the only event that gets triggered while dragging on a cell, and the drop hint status needs to be changed while crossing the 50% of cell width
| &.isDropping { | ||
| background: rgb(82, 79, 79); | ||
| } | ||
| } |
There was a problem hiding this comment.
Is this according to the UX? Or is this just a placeholder for now? #Closed
There was a problem hiding this comment.
| > | ||
| { column.ariaLabel } | ||
| </label> | ||
| ) : null,*/ |
There was a problem hiding this comment.
) : null,*/ [](start = 18, length = 11)
Please remove commented code from this file. #Closed
| onClick={ this._onColumnClick.bind(this, column) } | ||
| aria-haspopup={ column.columnActionsMode === ColumnActionsMode.hasDropdown } | ||
| > | ||
| (columnReorderOptions && _isDraggable) && this._renderDropHint(columnIndex), |
There was a problem hiding this comment.
columnReorderOptions && [](start = 17, length = 23)
Required? #Closed
| ] | ||
| ); | ||
| }) | ||
| }) } |
There was a problem hiding this comment.
} [](start = 13, length = 1)
Please fix formating. This should go to next line. #Closed
| // TODO - Handle CSS changes | ||
| } | ||
|
|
||
| private _getDragDropColumnEvents(): IDragDropEvents { |
There was a problem hiding this comment.
private _getDragDropColumnEvents(): IDragDropEvents [](start = 2, length = 51)
Why is this required? We can do whatever we are doing here inside IDragDropOptions. #Closed
| this._events.on(activeTarget.target.root, 'mouseleave', this._onMouseLeave.bind(this, activeTarget.target)); | ||
| } | ||
| } | ||
| // To prevent marquee selection on draggable targets |
There was a problem hiding this comment.
To prevent [](start = 9, length = 10)
Or simply -
'Prevent marquee selection on draggable targets' #Closed
| const { column, columnIndex, parentId } = this.props; | ||
| const { onRenderColumnHeaderTooltip = this._onRenderColumnHeaderTooltip | ||
| } = this.props; | ||
| const isDraggable = this.props.isDraggable; |
There was a problem hiding this comment.
const isDraggable = this.props.isDraggable; [](start = 4, length = 43)
merge this with 2 above ? #Closed
|
|
||
| private _onDragEnd(item?: any, event?: MouseEvent): void { | ||
| this.props.setDraggedItemIndex!(-1); | ||
| event!.preventDefault(); |
There was a problem hiding this comment.
event!.preventDefault(); [](start = 4, length = 24)
Why is this required? #Closed
| private _updateDroppingState(newValue: boolean, event: DragEvent): void { | ||
| if ((newValue === false || this._draggedColumnIndex === -1) && event.type !== 'drop') { | ||
| const newDropHintState = this.state.dropHintsState!.map(state => false); | ||
| this.setState({ dropHintsState: newDropHintState }); |
There was a problem hiding this comment.
this.setState({ dropHintsState: newDropHintState }); [](start = 6, length = 52)
Pass in a function instead. This way of updating the state is not reliable. #Closed
| onColumnContextMenu?: (column: IColumn, ev: React.MouseEvent<HTMLElement>) => void; | ||
| dragDropHelper?: IDragDropHelper | null; | ||
| isDraggable?: boolean; | ||
| setDraggedItemIndex?: (itemIndex: number) => void; |
There was a problem hiding this comment.
setDraggedItemIndex?: (itemIndex: number) => void; [](start = 2, length = 50)
Rather than this, the notification should be simple - like 'onColumnDragStart' with no params. The params (index) can be handled inside the DetailsHeader, where this callback is binded to a function. #Closed
erichdev
left a comment
There was a problem hiding this comment.
When dragging columns, I'm seeing a big performance hit if the drag lasts more than a ~second (i.e. try dragging for a few seconds before releasing). setState is called as you drag, forcing constant rerendering. Quick testing locally shows adding shouldComponentUpdate to DetailsHeader fixes it -- return true if dropHintsState doesn't exists or if new dropHintsState != current dropHintsState.
|
@erichdev, the issue of frequent renders has been fixed in the latest commit. Now DetailsHeader will get re-rendered only when there is a change in the drop hints. |
| onRenderColumnHeaderTooltip = this._onRenderColumnHeaderTooltip | ||
| } = this.props; | ||
|
|
||
| if (!this._dragDropHelper) { |
There was a problem hiding this comment.
if (!this._dragDropHelper) [](start = 4, length = 26)
if (!this._dragDropHelper && this.props.columenReorderOptions) {
this._dragDropHelper = new DragDropHelper();
} #Closed
| this._draggedColumnIndex = -1; | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Remove the extra line. #Closed
| } | ||
|
|
||
| private _onDrop(item?: any, event?: DragEvent): void { | ||
| if (this._draggedColumnIndex !== -1 && event! instanceof DragEvent) { |
There was a problem hiding this comment.
this._draggedColumnIndex !== -1 [](start = 8, length = 31)
A better check for 'valid' draggedColumnIndex would be a non-negative check. #Closed
| let indexToUpdate = -1; | ||
| if (eventXposition <= this._dropHintOriginXValues[currentIndex]) { | ||
|
|
||
| indexToUpdate = currentIndex; |
e736018 to
0451931
Compare
|
Hey @laxmikankanala, it looks like the values are truncated way too early. That's why I rejected the screener test. Can you check that out? |
|
Hey Ben,
I just looked at the screenshots for screener test. Seems that these are expected after the increase in left padding (+5px). This regression was called out during the design iteration as well. @piyush<mailto:Piyush.Belchandan@microsoft.com> @niket<mailto:Jain.Niket@microsoft.com>
~Shreyansh Agrawal
…________________________________
From: Ben Truelove <notifications@github.com>
Sent: Wednesday, June 20, 2018 8:55:00 PM
To: OfficeDev/office-ui-fabric-react
Cc: Shreyansh Agrawal; Manual
Subject: Re: [OfficeDev/office-ui-fabric-react] DetailsList: adding an optional column re-ordering feature (#4857)
Hey @laxmikankanala<https://github.com/laxmikankanala>, it looks like the values are truncated way too early. That's why I rejected the screener test. Can you check that out?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#4857 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AkO_B3tXToU6EKAaV06lAB8BzADcJentks5t-mlLgaJpZM4T8sZS>.
|
There was a problem hiding this comment.
Signing off. Please have @yiminwu / @ThomasMichon and @betrue-final-final take a look and approve as well.
| } | ||
| } | ||
|
|
||
| .GripperBarVerticalStyle { |
There was a problem hiding this comment.
nit: can we change to start with lowcase to match others?
| text-overflow: clip; | ||
| } | ||
|
|
||
| &:hover .GripperBarVerticalStyle { |
There was a problem hiding this comment.
GripperBarVerticalStyle [](start = 11, length = 23)
same here
|
@betrue-final-final, we have fixed the right padding issue. Can you please review now. |
|
I wasn't quite up then, but I just checked it. It was 5:30AM PST ✌️ |

Pull request checklist
$ npm run changeDescription of changes
Column Reorder support in DetailsList using drag and drop
Based on the mouse position of the event, column target position will be decided.
There is an optional parameter to specify frozen columns to keep the position of those columns intact.
Pending things:
Focus areas to test
Functionality of Column reorder