Skip to content

Commit

Permalink
Alternative implementation - no onBlurCaption function
Browse files Browse the repository at this point in the history
  • Loading branch information
mchowning committed Apr 15, 2019
1 parent 98785ab commit ea31547
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class ImageEdit extends React.Component {
this.onImagePressed = this.onImagePressed.bind( this );
this.onClearSettings = this.onClearSettings.bind( this );
this.onFocusCaption = this.onFocusCaption.bind( this );
this.onBlurCaption = this.onBlurCaption.bind( this );
}

componentDidMount() {
Expand Down Expand Up @@ -121,6 +120,9 @@ class ImageEdit extends React.Component {
}

this._caption.blur();
this.setState( {
isCaptionSelected: false,
} );
}

mediaUpload( payload ) {
Expand Down Expand Up @@ -233,17 +235,6 @@ class ImageEdit extends React.Component {
}
}

onBlurCaption() {
if ( this.props.onBlur ) {
this.props.onBlur();
}
if ( this.state.isCaptionSelected ) {
this.setState( {
isCaptionSelected: false,
} );
}
}

render() {
const { attributes, isSelected, setAttributes } = this.props;
const { url, caption, height, width, alt, href } = attributes;
Expand Down Expand Up @@ -430,7 +421,7 @@ class ImageEdit extends React.Component {
value={ caption }
onChange={ ( newCaption ) => setAttributes( { caption: newCaption } ) }
onFocus={ this.onFocusCaption }
onBlur={ this.onBlurCaption }
//onBlur={ this.props.onBlur } // always assign onBlur as props (??)
isSelected={ this.state.isCaptionSelected }
fontSize={ 14 }
underlineColorAndroid="transparent"
Expand Down

0 comments on commit ea31547

Please sign in to comment.