Skip to content
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

Refactor Draggable to decouple drag handle from the DOM node being dragged #9311

Merged
merged 24 commits into from
Sep 3, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b435722
Add withDraggable HOC
oandregal Aug 24, 2018
b5a35cd
Deprecate Draggable
oandregal Aug 24, 2018
18ef675
Convert block-draggable into class
oandregal Aug 27, 2018
2d48f1a
Inline Draggable component
oandregal Aug 27, 2018
26a0b6f
Use withDraggable
oandregal Aug 27, 2018
2ca2e4a
Pass props to wrapped component
oandregal Aug 29, 2018
eb0c491
withDraggable is responsible to call the props passed to the wrapped …
oandregal Aug 29, 2018
f545653
BlockDraggable: adapt to new API
oandregal Aug 29, 2018
7610b9e
Fix dragend event handler
oandregal Aug 29, 2018
c9b44f2
withDraggable's event handlers take control
oandregal Aug 29, 2018
07d1749
Make setTimeout property available within withDraggable
oandregal Aug 29, 2018
06ae3ba
Do not pass dragover to children
oandregal Aug 29, 2018
d9a1807
Make Draggable ready to process children functions
oandregal Aug 30, 2018
25297ce
Remove any traces of withDraggable HOC
oandregal Aug 30, 2018
cc43d33
Move deprecation to correct version
oandregal Aug 30, 2018
0427c19
BlockDraggable: convert it back to a functional component
oandregal Aug 30, 2018
f340eca
Update docs
oandregal Aug 30, 2018
7829554
Update docs
oandregal Aug 30, 2018
2d4c207
Clarify BlockDraggable abstraction
oandregal Aug 30, 2018
96c337c
Update docs
oandregal Aug 30, 2018
7cd7f62
Update deprecation
oandregal Aug 30, 2018
f568bf5
Add note in CHANGELOG
oandregal Aug 30, 2018
755e0aa
Update version that will depracate the behavior
oandregal Aug 30, 2018
32006d3
Add deprecation within 4.0 section
oandregal Sep 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clarify BlockDraggable abstraction
It is the component that build the necessary transfer data
to drag a block around.
  • Loading branch information
oandregal committed Sep 3, 2018
commit 2d4c207d223d980bd28cd9c572e2bca8597ee603
12 changes: 10 additions & 2 deletions packages/editor/src/components/block-list/block-draggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ import classnames from 'classnames';
*/
import { Draggable } from '@wordpress/components';

const BlockDraggable = ( { isDragging, elementId, transferData, onDragStart, onDragEnd } ) => {
const BlockDraggable = ( { clientId, rootClientId, blockElementId, layout, order, isDragging, onDragStart, onDragEnd } ) => {
const className = classnames( 'editor-block-list__block-draggable', {
'is-visible': isDragging,
} );

const transferData = {
type: 'block',
fromIndex: order,
rootClientId,
clientId,
layout,
};

return (
<Draggable
elementId={ elementId }
elementId={ blockElementId }
transferData={ transferData }
onDragStart={ onDragStart }
onDragEnd={ onDragEnd }
Expand Down
13 changes: 5 additions & 8 deletions packages/editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,14 +483,11 @@ export class BlockListBlock extends Component {
>
{ ! isPartOfMultiSelection && isMovable && (
<BlockDraggable
elementId={ blockElementId }
transferData={ {
type: 'block',
fromIndex: order,
rootClientId,
clientId,
layout,
} }
clientId={ clientId }
rootClientId={ rootClientId }
blockElementId={ blockElementId }
layout={ layout }
order={ order }
onDragStart={ this.onDragStart }
onDragEnd={ this.onDragEnd }
isDragging={ dragging }
Expand Down