Skip to content

Commit

Permalink
select contents on focus
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Silverstein committed May 21, 2018
1 parent bce05aa commit fda66b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 9 additions & 4 deletions edit-post/components/sidebar/post-author/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class PostAuthor extends Component {
constructor() {
super( ...arguments );
this.onSelect = this.onSelect.bind( this );
this.onBlur = this.onBlur.bind( this );
this.onFocus = this.onFocus.bind( this );
this.state = {
theAuthor: false,
};
Expand All @@ -42,8 +42,13 @@ export class PostAuthor extends Component {
onUpdateAuthor( Number( value.id ) );
}

onBlur( content ) {
//this.onSelect( content[1] )
onFocus( editor ) {
if ( ! editor.dom ) {
return;
}
const range = editor.dom.createRng();
range.selectNodeContents(editor.getBody());
editor.selection.setRng(range);
}


Expand All @@ -69,7 +74,7 @@ export class PostAuthor extends Component {
onSelect={ this.onSelect }
onChange={ () => {} }
autocompleters={ [ authorAutocompleter ] }
onBlur={ this.onBlur }
onFocus={ this.onFocus }
/>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions editor/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ export class RichText extends Component {
if ( this.props.setFocusedElement ) {
this.props.setFocusedElement( this.props.instanceId );
}

if ( this.props.onFocus ) {
this.props.onFocus( this.editor );
}
}

/**
Expand Down

0 comments on commit fda66b1

Please sign in to comment.