Skip to content

Commit 14d482b

Browse files
committed
[RNMobile] Insure tapping at end of post inserts at end
Previously, tapping at the end of the post would insert a block immediately after the currently selected block. In addition, this commit is cleaning out a few unusued props in the block-list file.
1 parent 7b12673 commit 14d482b

File tree

1 file changed

+4
-28
lines changed

1 file changed

+4
-28
lines changed

packages/block-editor/src/components/block-list/index.native.js

+4-28
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,12 @@ export class BlockList extends Component {
3333
this.renderDefaultBlockAppender = this.renderDefaultBlockAppender.bind( this );
3434
this.onCaretVerticalPositionChange = this.onCaretVerticalPositionChange.bind( this );
3535
this.scrollViewInnerRef = this.scrollViewInnerRef.bind( this );
36-
this.getNewBlockInsertionIndex = this.getNewBlockInsertionIndex.bind( this );
36+
this.addBlockToEndOfPost = this.addBlockToEndOfPost.bind( this );
3737
this.shouldFlatListPreventAutomaticScroll = this.shouldFlatListPreventAutomaticScroll.bind( this );
3838
}
3939

40-
finishBlockAppendingOrReplacing( newBlock ) {
41-
// now determine whether we need to replace the currently selected block (if it's empty)
42-
// or just add a new block as usual
43-
if ( this.isReplaceable( this.props.selectedBlock ) ) {
44-
// do replace here
45-
this.props.replaceBlock( this.props.selectedBlockClientId, newBlock );
46-
} else {
47-
this.props.insertBlock( newBlock, this.getNewBlockInsertionIndex() );
48-
}
49-
}
50-
51-
getNewBlockInsertionIndex() {
52-
if ( this.props.isPostTitleSelected ) {
53-
// if post title selected, insert at top of post
54-
return 0;
55-
} else if ( this.props.selectedBlockIndex === -1 ) {
56-
// if no block selected, insert at end of post
57-
return this.props.blockCount;
58-
}
59-
// insert after selected block
60-
return this.props.selectedBlockIndex + 1;
40+
addBlockToEndOfPost( newBlock ) {
41+
this.props.insertBlock( newBlock, this.props.blockCount );
6142
}
6243

6344
blockHolderBorderStyle() {
@@ -162,7 +143,7 @@ export class BlockList extends Component {
162143
const paragraphBlock = createBlock( 'core/paragraph' );
163144
return (
164145
<TouchableWithoutFeedback onPress={ () => {
165-
this.finishBlockAppendingOrReplacing( paragraphBlock );
146+
this.addBlockToEndOfPost( paragraphBlock );
166147
} } >
167148
<View style={ styles.blockListFooter } />
168149
</TouchableWithoutFeedback>
@@ -174,10 +155,8 @@ export default compose( [
174155
withSelect( ( select, { rootClientId } ) => {
175156
const {
176157
getBlockCount,
177-
getBlockName,
178158
getBlockIndex,
179159
getBlockOrder,
180-
getSelectedBlock,
181160
getSelectedBlockClientId,
182161
getBlockInsertionPoint,
183162
isBlockInsertionPointVisible,
@@ -210,13 +189,10 @@ export default compose( [
210189
return {
211190
blockClientIds,
212191
blockCount: getBlockCount( rootClientId ),
213-
getBlockName,
214192
isBlockInsertionPointVisible: isBlockInsertionPointVisible(),
215193
shouldShowBlockAtIndex,
216194
shouldShowInsertionPoint,
217-
selectedBlock: getSelectedBlock(),
218195
selectedBlockClientId,
219-
selectedBlockIndex,
220196
};
221197
} ),
222198
withDispatch( ( dispatch ) => {

0 commit comments

Comments
 (0)