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
[CARBON-865] CustomDragLayer component for enabling Drag & Drop ghost row #1439
Conversation
Went to have a play with it and got this error - react-dnd/react-dnd#431 Caused by this - https://github.com/react-dnd/react-dnd/blob/ca10e688651833d10b378a2a1bf284a0264ed4c8/packages/react-dnd/src/DragLayer.js#L96-L105 Possible workaround at the bottom of the issue |
@SeanArmstrong thanks for the heads up, I've managed to remove the error. I've updated the So for the It might still be worth splitting |
b8ebf58
to
f2a9669
Compare
Work on this has paused due to the difficulty of placing the ghost layer inside the table which renders the html markup invalid. |
8278a82
to
6f54adf
Compare
This has now been refactored so that the Tested on the following browsers:
|
dc3d219
to
d5c64ea
Compare
Unfortunately Safari is not displaying the 'grabbing' cursor when dragging and instead shows the text cursor. |
f988c31
to
2e5ed88
Compare
I have raised separate tickets for the issue with the Safari cursor and the performance of the DraggableContext component on the Carbon site. CARBON-942 and CARBON-939. |
return ( | ||
<div className='carbon-draggable-context'> | ||
{ this.props.children } | ||
<CustomDragLayer /> |
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.
Could this pass some DragLayerProps so that its easier to change the custom drag layer.
Or enable a way so that you can optionally pass your own custom drag layer.
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.
Yeah I like the idea of being able to pass in your own drag layer into the Draggable Context.
2e5ed88
to
7344617
Compare
In order to enable this you need to define the `draggableNode` prop on the `<WithDrag>` component. For example: ``` class DraggableItems extends React.Component { render() { return ( <DraggableContext onDrag={ onItemMoved }> <ol> { items.map((item, index) => { return ( <WithDrop key={ index } index={ index }> <DraggableItem /> </WithDrop> ); }); } </ol> </DraggableContext> ); } } ... class DraggableItem extends React.Component { render() { return ( <li ref={ (node) => { this._listItem = node; } } > <WithDrag draggableNode={ () => { return this._listItem; } }> <span>{ item.content }</span> </WithDrag> </li> ); } } ``` Note that the `draggableNode` is passed as a function because the ref `_listItem` is undefined until the component is mounted.
927d75b
to
19b052b
Compare
446b279
to
9ffd6d0
Compare
9ffd6d0
to
7cb72ca
Compare
In order to enable this you need to define the `draggableNode` prop on the `<WithDrag>` component. For example: ``` class DraggableItems extends React.Component { render() { return ( <DraggableContext onDrag={ onItemMoved }> <ol> { items.map((item, index) => { return ( <WithDrop key={ index } index={ index }> <DraggableItem /> </WithDrop> ); }); } </ol> </DraggableContext> ); } } ... class DraggableItem extends React.Component { render() { return ( <li ref={ (node) => { this._listItem = node; } } > <WithDrag draggableNode={ () => { return this._listItem; } }> <span>{ item.content }</span> </WithDrag> </li> ); } } ``` Note that the `draggableNode` is passed as a function because the ref `_listItem` is undefined until the component is mounted.
7cb72ca
to
1b36110
Compare
Re-QA'd after further improvements have been made. As previously fine in all browsers other than the Safari icon issue already logged. QA Passed. |
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.
will wait to see if we get anywhere with #1494 before merging
Use 'selectstart' event listener to call preventDefault if the user is dragging a dom node or is already dragging.
Fix Safari cursor for drag and drop
Ticket CARBON-865
Implemented by using: https://react-dnd.github.io/react-dnd/docs-drag-layer.html
Chrome
Firefox
Edge
TODO: