Skip to content

Commit

Permalink
Don't allow to start dragging blocks if a lock all exists (#7225)
Browse files Browse the repository at this point in the history
Don't allow to start dragging blocks if a locking lock all exists.
Refactor block hover and select CSS to not rely on draggable.
  • Loading branch information
jorgefilipecosta authored Jun 26, 2018
1 parent 8fa8b64 commit d316177
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
4 changes: 3 additions & 1 deletion editor/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ export class BlockListBlock extends Component {
hoverArea,
isLargeViewport,
isEmptyDefaultBlock,
isMovable,
isPreviousBlockADefaultEmptyBlock,
hasSelectedInnerBlock,
} = this.props;
Expand Down Expand Up @@ -470,7 +471,7 @@ export class BlockListBlock extends Component {
] }
{ ...wrapperProps }
>
{ ! isMultiSelected && (
{ ! isMultiSelected && isMovable && (
<BlockDraggable
rootUID={ rootUID }
index={ order }
Expand Down Expand Up @@ -620,6 +621,7 @@ const applyWithSelect = withSelect( ( select, { uid, rootUID } ) => {
initialPosition: getSelectedBlocksInitialCaretPosition(),
isEmptyDefaultBlock: block && isUnmodifiedDefaultBlock( block ),
isPreviousBlockADefaultEmptyBlock: previousBlock && isUnmodifiedDefaultBlock( previousBlock ),
isMovable: 'all' !== templateLock,
isLocked: !! templateLock,
previousBlockUid,
block,
Expand Down
27 changes: 27 additions & 0 deletions editor/components/block-list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -934,3 +934,30 @@
content: '';
}
}

.editor-block-list__block {
@include break-small {
// Increase the hover and selection area around blocks.
// This makes the blue hover line and the settings button appear even if
// the mouse cursor is technically outside the block.
// This improves usability by making it possible to click somewhat outside
// the block and select it. (eg. A fuzzy click target.)
&:before {
bottom: 0;
content: '';
left: -$parent-block-padding - $block-padding;
position: absolute;
right: -$parent-block-padding - $block-padding;
top: 0;
}

// Remove the fuzzy click area effect set above on nested blocks.
// It should only applies to top-level blocks; applying this rule to
// nested blocks will result in difficult-to-use and possibly overlapping
// click targets.
& &:before {
left: 0;
right: 0;
}
}
}

0 comments on commit d316177

Please sign in to comment.