From a095e5216676d7905dd3157f10b9f86bc09f138b Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Wed, 21 Mar 2018 12:02:53 -0400 Subject: [PATCH] Blocks: Explicitly select embed block on focus Previously would work just as well, but unintentionally passes argument of type Event to setIsSelected via pass-through of onFocus handler --- blocks/library/embed/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/blocks/library/embed/index.js b/blocks/library/embed/index.js index 4d8b08e494285..9da17ecda1291 100644 --- a/blocks/library/embed/index.js +++ b/blocks/library/embed/index.js @@ -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: '', @@ -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. @@ -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 && ( @@ -204,7 +211,7 @@ function getEmbedBlockSettings( { title, icon, category = 'embed', transforms, k html={ html } title={ iframeTitle } type={ type } - onFocus={ setIsSelected } + onFocus={ this.setIsSelected } /> );