Skip to content

Commit

Permalink
Remove the isFocused check
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Mar 28, 2017
1 parent cf04a33 commit f80239f
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions blocks/components/editable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ export default class Editable extends wp.element.Component {
this.onInit = this.onInit.bind( this );
this.onSetup = this.onSetup.bind( this );
this.onChange = this.onChange.bind( this );
this.onFocusIn = this.onFocusIn.bind( this );
this.onFocusOut = this.onFocusOut.bind( this );
this.bindNode = this.bindNode.bind( this );
}

Expand All @@ -32,8 +30,7 @@ export default class Editable extends wp.element.Component {
onSetup( editor ) {
this.editor = editor;
editor.on( 'init', this.onInit );
editor.on( 'focusIn', this.onFocusIn );
editor.on( 'focusout', this.onFocusOut );
editor.on( 'focusout', this.onChange );
}

onInit() {
Expand All @@ -49,28 +46,14 @@ export default class Editable extends wp.element.Component {
this.props.onChange( value );
}

onFocusIn() {
this.isFocused = true;
}

onFocusOut() {
this.isFocused = false;
this.onChange();
}

bindNode( ref ) {
this.node = ref;
}

updateContent() {
let bookmark;
if ( this.isFocused ) {
bookmark = this.editor.selection.getBookmark( 2, true );
}
const bookmark = this.editor.selection.getBookmark( 2, true );
this.editor.setContent( this.props.value );
if ( this.isFocused ) {
this.editor.selection.moveToBookmark( bookmark );
}
this.editor.selection.moveToBookmark( bookmark );
}

componentWillUnmount() {
Expand Down

0 comments on commit f80239f

Please sign in to comment.