Skip to content

Commit

Permalink
Don't allow to start dragging blocks if a locking lock all exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Jun 8, 2018
1 parent c7ce08b commit ececee1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
8 changes: 8 additions & 0 deletions components/draggable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

The component accepts the following props:

### draggable

If the component is in a draggable state or not. If false, the component is rendered but it is not possible to drag it. Defaults to true.

- Type: `boolean`
- Required: No
- Default: `true`

### elementId

The HTML id of the element to clone on drag
Expand Down
4 changes: 2 additions & 2 deletions components/draggable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ class Draggable extends Component {
}

render() {
const { children, className } = this.props;
const { children, draggable = true, className } = this.props;
return (
<div
className={ classnames( 'components-draggable', className ) }
onDragStart={ this.onDragStart }
onDragEnd={ this.onDragEnd }
draggable
draggable={ draggable }
>
{ children }
</div>
Expand Down
3 changes: 3 additions & 0 deletions editor/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ export class BlockListBlock extends Component {
isEmptyDefaultBlock,
isPreviousBlockADefaultEmptyBlock,
hasSelectedInnerBlock,
templateLock,
} = this.props;
const isHovered = this.state.isHovered && ! isMultiSelecting;
const { name: blockName, isValid } = block;
Expand Down Expand Up @@ -504,6 +505,7 @@ export class BlockListBlock extends Component {
onDragEnd={ this.onDragEnd }
isDragging={ dragging }
elementId={ blockElementId }
draggable={ 'all' !== templateLock } // only in locking all moving blocks is totally impossible
/>
) }
{ shouldShowInsertionPoint && (
Expand Down Expand Up @@ -646,6 +648,7 @@ const applyWithSelect = withSelect( ( select, { uid, rootUID } ) => {
initialPosition: getSelectedBlocksInitialCaretPosition(),
isEmptyDefaultBlock: block && isUnmodifiedDefaultBlock( block ),
isPreviousBlockADefaultEmptyBlock: previousBlock && isUnmodifiedDefaultBlock( previousBlock ),
templateLock,
isLocked: !! templateLock,
previousBlockUid,
block,
Expand Down
7 changes: 4 additions & 3 deletions editor/components/block-list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@
}
}


cursor: move; // Fallback for IE/Edge < 14
cursor: grab;
&[draggable=true]{
cursor: move; // Fallback for IE/Edge < 14
cursor: grab;
}
}


Expand Down

0 comments on commit ececee1

Please sign in to comment.