Skip to content

Commit

Permalink
[RNMobile] Correct post title focus (#23683)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewalczak authored Jul 9, 2020
1 parent 587b018 commit 572c1bc
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/editor/src/components/post-title/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,21 @@ import { pasteHandler } from '@wordpress/blocks';
import styles from './style.scss';

class PostTitle extends Component {
constructor( props ) {
super( props );

this.setRef = this.setRef.bind( this );
}
componentDidUpdate( prevProps ) {
// Unselect if any other block is selected
// Unselect if any other block is selected and blur the RichText
if (
this.props.isSelected &&
! prevProps.isAnyBlockSelected &&
this.props.isAnyBlockSelected
) {
if ( this.richTextRef ) {
this.richTextRef.blur();
}
this.props.onUnselect();
}
}
Expand Down Expand Up @@ -64,6 +72,10 @@ class PostTitle extends Component {
}
}

setRef( richText ) {
this.richTextRef = richText;
}

render() {
const {
placeholder,
Expand Down Expand Up @@ -100,6 +112,7 @@ class PostTitle extends Component {
}
>
<RichText
setRef={ this.setRef }
tagName={ 'p' }
tagsToEliminate={ [ 'strong' ] }
unstableOnFocus={ this.props.onSelect }
Expand Down

0 comments on commit 572c1bc

Please sign in to comment.