Fixed buttons, make sure som is passed to render

This commit is contained in:
Justin Foell
2020-11-27 15:39:14 -06:00
parent d92ed860f3
commit d3b2901b68
4 changed files with 49 additions and 34 deletions
+11 -1
View File
@@ -18,11 +18,13 @@ class Edit extends Component {
this.switchBackToURLInput = this.switchBackToURLInput.bind( this );
this.toggleImageOnly = this.toggleImageOnly.bind( this );
this.toggleDisplayMarkers = this.toggleDisplayMarkers.bind( this );
this.overrideSOM = this.overrideSOM.bind( this );
this.state = {
url: this.props.attributes.url,
imageOnly: this.props.attributes.imageOnly,
displayMarkers: this.props.attributes.displayMarkers,
som: this.props.attributes.som,
editingURL: isEmpty( this.props.attributes.url ) ? true : false,
};
}
@@ -49,12 +51,18 @@ class Edit extends Component {
this.props.setAttributes( { displayMarkers: checked } );
}
overrideSOM( newSOM ) {
this.setState( { som: newSOM } );
this.props.setAttributes( { som: newSOM } );
}
render() {
const {
url,
editingURL,
imageOnly,
displayMarkers,
som
} = this.state;
// Newly inserted block or we've clicked the edit button.
@@ -83,6 +91,7 @@ class Edit extends Component {
url: url,
imageOnly: imageOnly,
displayMarkers: displayMarkers,
som: som,
} }
/>
<InspectorControls>
@@ -100,7 +109,8 @@ class Edit extends Component {
onChange={ (checked ) => this.toggleDisplayMarkers( checked ) }
/>
<SOMOverride
onChange={ ( value ) => this.props.setAttributes( { som: value } ) }
onChange={ ( value ) => this.overrideSOM( value ) }
som={ som }
/>
</PanelBody>
</InspectorControls>