From e2346f14cac8333605aee8399c47b3679132784e Mon Sep 17 00:00:00 2001 From: Danilo Ercoli Date: Fri, 25 Jan 2019 21:28:50 +0100 Subject: [PATCH] Remove the custom mobile code, and use the default web implementation --- .../src/components/post-title/index.native.js | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/packages/editor/src/components/post-title/index.native.js b/packages/editor/src/components/post-title/index.native.js index f6a22939f2445c..1ce2384db72ea6 100644 --- a/packages/editor/src/components/post-title/index.native.js +++ b/packages/editor/src/components/post-title/index.native.js @@ -12,11 +12,6 @@ import { withDispatch } from '@wordpress/data'; import { withFocusOutside } from '@wordpress/components'; import { withInstanceId, compose } from '@wordpress/compose'; -import { - getDefaultBlockName, - createBlock, -} from '@wordpress/blocks'; - class PostTitle extends Component { constructor() { super( ...arguments ); @@ -24,7 +19,6 @@ class PostTitle extends Component { this.onChange = this.onChange.bind( this ); this.onSelect = this.onSelect.bind( this ); this.onUnselect = this.onUnselect.bind( this ); - this.onEnter = this.onEnter.bind( this ); this.state = { isSelected: false, @@ -48,14 +42,6 @@ class PostTitle extends Component { this.props.onUpdate( title ); } - onEnter( ) { - const { insertBlocksAfter } = this.props; - if ( ! insertBlocksAfter ) { - return; - } - insertBlocksAfter( [ createBlock( getDefaultBlockName() ) ] ); - } - render() { const { placeholder, @@ -70,7 +56,7 @@ class PostTitle extends Component { blurOnSubmit={ true } textAlignVertical="top" multiline={ false } - onSubmitEditing={ this.onEnter } + onSubmitEditing={ this.props.onEnterPress } returnKeyType={ 'next' } onChangeText={ this.onChange } onFocus={ this.onSelect } @@ -84,10 +70,14 @@ class PostTitle extends Component { const applyWithDispatch = withDispatch( ( dispatch ) => { const { + insertDefaultBlock, clearSelectedBlock, } = dispatch( 'core/editor' ); return { + onEnterPress() { + insertDefaultBlock( undefined, undefined, 0 ); + }, clearSelectedBlock, }; } );