diff --git a/editor/components/writing-flow/index.js b/editor/components/writing-flow/index.js index d267b7450308..59f7568cf123 100644 --- a/editor/components/writing-flow/index.js +++ b/editor/components/writing-flow/index.js @@ -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 @@ -22,7 +22,6 @@ import { /** * Internal dependencies */ -import { BlockListBlock } from '../block-list/block'; import { getPreviousBlockUid, getNextBlockUid, @@ -32,7 +31,6 @@ import { } from '../../store/selectors'; import { multiSelect, - insertDefaultBlock, selectBlock, } from '../../store/actions'; @@ -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 ); @@ -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; @@ -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() { @@ -267,7 +223,6 @@ export default connect( } ), { onMultiSelect: multiSelect, - onBottomReached: insertDefaultBlock, onSelectBlock: selectBlock, } )( WritingFlow );