Skip to content

Commit

Permalink
Writing Flow: Remove onBottomReached handling (#5271)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth authored Feb 27, 2018
1 parent d24245c commit cc87946
Showing 1 changed file with 1 addition and 46 deletions.
47 changes: 1 addition & 46 deletions editor/components/writing-flow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { connect } from 'react-redux';
import 'element-closest';
import { find, last, reverse, get } from 'lodash';
import { find, reverse, get } from 'lodash';

/**
* WordPress dependencies
Expand All @@ -22,7 +22,6 @@ import {
/**
* Internal dependencies
*/
import { BlockListBlock } from '../block-list/block';
import {
getPreviousBlockUid,
getNextBlockUid,
Expand All @@ -32,7 +31,6 @@ import {
} from '../../store/selectors';
import {
multiSelect,
insertDefaultBlock,
selectBlock,
} from '../../store/actions';

Expand All @@ -41,10 +39,6 @@ import {
*/
const { UP, DOWN, LEFT, RIGHT } = keycodes;

function isElementNonEmpty( el ) {
return !! el.innerText.trim();
}

class WritingFlow extends Component {
constructor() {
super( ...arguments );
Expand Down Expand Up @@ -109,37 +103,6 @@ class WritingFlow extends Component {
} );
}

isInLastNonEmptyBlock( target ) {
const tabbables = this.getVisibleTabbables();

// Find last tabbable, compare with target
const lastTabbable = last( tabbables );
if ( ! lastTabbable || ! lastTabbable.contains( target ) ) {
return false;
}

// Find block-level ancestor of said last tabbable
const blockEl = lastTabbable.closest( '.' + BlockListBlock.className );
const blockIndex = tabbables.indexOf( blockEl );

// Unexpected, so we'll leave quietly.
if ( blockIndex === -1 ) {
return false;
}

// Maybe there are no descendants, and the target is the block itself?
if ( lastTabbable === blockEl ) {
return isElementNonEmpty( blockEl );
}

// Otherwise, find the descendants of the ancestor, i.e. the target and
// its siblings, and check them instead.
return tabbables
.slice( blockIndex + 1 )
.some( ( el ) =>
blockEl.contains( el ) && isElementNonEmpty( el ) );
}

expandSelection( currentStartUid, isReverse ) {
const { previousBlockUid, nextBlockUid } = this.props;

Expand Down Expand Up @@ -229,13 +192,6 @@ class WritingFlow extends Component {
this.selectParentBlock( closestTabbable );
event.preventDefault();
}

if ( isDown && ! isShift && ! hasMultiSelection &&
this.isInLastNonEmptyBlock( target ) &&
isVerticalEdge( target, false, false )
) {
this.props.onBottomReached();
}
}

render() {
Expand Down Expand Up @@ -267,7 +223,6 @@ export default connect(
} ),
{
onMultiSelect: multiSelect,
onBottomReached: insertDefaultBlock,
onSelectBlock: selectBlock,
}
)( WritingFlow );

0 comments on commit cc87946

Please sign in to comment.