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

Keyboard multiselect: support horizontal arrows #3245

Merged
merged 1 commit into from
Oct 30, 2017
Merged
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions editor/writing-flow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down