Skip to content

Commit

Permalink
Blocks: Explicitly select embed block on focus
Browse files Browse the repository at this point in the history
Previously would work just as well, but unintentionally passes argument of type Event to setIsSelected via pass-through of onFocus handler
  • Loading branch information
aduth committed Mar 21, 2018
1 parent 91b0b90 commit a095e52
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions blocks/library/embed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ function getEmbedBlockSettings( { title, icon, category = 'embed', transforms, k
edit: class extends Component {
constructor() {
super( ...arguments );

this.doServerSideRender = this.doServerSideRender.bind( this );
this.setIsSelected = this.setIsSelected.bind( this );

this.state = {
html: '',
type: '',
Expand All @@ -96,6 +99,10 @@ function getEmbedBlockSettings( { title, icon, category = 'embed', transforms, k
this.unmounting = true;
}

setIsSelected() {
this.props.setIsSelected( true );
}

getPhotoHtml( photo ) {
// 100% width for the preview so it fits nicely into the document, some "thumbnails" are
// acually the full size photo.
Expand Down Expand Up @@ -143,7 +150,7 @@ function getEmbedBlockSettings( { title, icon, category = 'embed', transforms, k
render() {
const { html, type, error, fetching } = this.state;
const { align, url, caption } = this.props.attributes;
const { setAttributes, isSelected, className, setIsSelected } = this.props;
const { setAttributes, isSelected, className } = this.props;
const updateAlignment = ( nextAlign ) => setAttributes( { align: nextAlign } );

const controls = isSelected && (
Expand Down Expand Up @@ -204,7 +211,7 @@ function getEmbedBlockSettings( { title, icon, category = 'embed', transforms, k
html={ html }
title={ iframeTitle }
type={ type }
onFocus={ setIsSelected }
onFocus={ this.setIsSelected }
/>
</div>
);
Expand Down

0 comments on commit a095e52

Please sign in to comment.