Skip to content

Commit

Permalink
Input Interaction: allow outer vertical edge to be selected
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Mar 15, 2019
1 parent 7723b06 commit a082816
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions packages/block-editor/src/components/writing-flow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,13 @@ class WritingFlow extends Component {
}

onKeyDown( event ) {
const { hasMultiSelection, onMultiSelect, blocks } = this.props;
const {
hasMultiSelection,
onMultiSelect,
blocks,
selectionBeforeEndClientId,
selectionAfterEndClientId,
} = this.props;

const { keyCode, target } = event;
const isUp = keyCode === UP;
Expand Down Expand Up @@ -281,13 +287,24 @@ class WritingFlow extends Component {
this.verticalRect = computeCaretRect( target );
}

if ( isShift && ( hasMultiSelection || (
this.isTabbableEdge( target, isReverse ) &&
isNavEdge( target, isReverse )
) ) ) {
// Shift key is down, and there is multi selection or we're at the end of the current block.
this.expandSelection( isReverse );
event.preventDefault();
if ( isShift ) {
if (
(
// Ensure that there is a target block.
( isReverse && selectionBeforeEndClientId ) ||
( ! isReverse && selectionAfterEndClientId )
) && (
hasMultiSelection || (
this.isTabbableEdge( target, isReverse ) &&
isNavEdge( target, isReverse )
)
)
) {
// Shift key is down, and there is multi selection or we're at
// the end of the current block.
this.expandSelection( isReverse );
event.preventDefault();
}
} else if ( hasMultiSelection ) {
// Moving from block multi-selection to single block selection
this.moveSelection( isReverse );
Expand Down

0 comments on commit a082816

Please sign in to comment.