From 16e2cc62c53e280b7ae82c02dc9475edeb12d3f2 Mon Sep 17 00:00:00 2001 From: Miguel Fonseca Date: Mon, 30 Oct 2017 16:15:51 +0000 Subject: [PATCH] Keyboard multiselect: support horizontal arrows --- editor/writing-flow/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/editor/writing-flow/index.js b/editor/writing-flow/index.js index 00b8d54dd80017..6509b98f474471 100644 --- a/editor/writing-flow/index.js +++ b/editor/writing-flow/index.js @@ -123,19 +123,22 @@ class WritingFlow extends Component { const isReverse = isUp || isLeft; const isHorizontal = isLeft || isRight; const isVertical = isUp || isDown; + const isNav = isHorizontal || isVertical; const isShift = event.shiftKey; + const isNavEdge = isVertical ? isVerticalEdge : isHorizontalEdge; + if ( ! isVertical ) { this.verticalRect = null; } else if ( ! this.verticalRect ) { this.verticalRect = computeCaretRect( target ); } - if ( isVertical && isShift && hasMultiSelection ) { + if ( isNav && isShift && hasMultiSelection ) { // Shift key is down and existing block selection event.preventDefault(); this.expandSelection( blocks, selectionStart, selectionEnd, isReverse ? -1 : +1 ); - } else if ( isVertical && isShift && this.isEditableEdge( isReverse, target ) && isVerticalEdge( target, isReverse, true ) ) { + } else if ( isNav && isShift && this.isEditableEdge( isReverse, target ) && isNavEdge( target, isReverse, true ) ) { // Shift key is down, but no existing block selection event.preventDefault(); this.expandSelection( blocks, selectedBlock.uid, selectedBlock.uid, isReverse ? -1 : +1 );