diff --git a/packages/vulcan-embed/lib/components/EmbedURL.jsx b/packages/vulcan-embed/lib/components/EmbedURL.jsx index 23c81f6af..fbfb195bc 100644 --- a/packages/vulcan-embed/lib/components/EmbedURL.jsx +++ b/packages/vulcan-embed/lib/components/EmbedURL.jsx @@ -3,7 +3,6 @@ import { withMutation } from 'meteor/vulcan:core'; import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { FormattedMessage, intlShape } from 'meteor/vulcan:i18n'; -import Form from 'react-bootstrap/Form'; class EmbedURL extends Component { constructor(props) { @@ -43,10 +42,9 @@ class EmbedURL extends Component { }; // called whenever the URL input field loses focus - handleBlur = async () => { + handleBlur = async e => { try { - // value from formsy input ref - const url = this.input.getValue(); + const url = e.target.value; // start the mutation only if the input has a value if (url.length) { @@ -60,7 +58,11 @@ class EmbedURL extends Component { // console.log('Embedly Data', result); // extract the relevant data, for easier consumption - const { data: { getEmbedData: { title, description, thumbnailUrl } } } = result; + const { + data: { + getEmbedData: { title, description, thumbnailUrl }, + }, + } = result; const body = description; // update the form @@ -91,7 +93,10 @@ class EmbedURL extends Component { this.setState({ loading: false }); // something bad happened - this.context.throwError({ id: 'embedurl.error_fetching_data', data: { name: this.props.path, message: errorMessage } }); + this.context.throwError({ + id: 'embedurl.error_fetching_data', + data: { name: this.props.path, message: errorMessage }, + }); } }; @@ -106,10 +111,26 @@ class EmbedURL extends Component { }; }; + getLoadingStyle = () => { + const loadingStyle = { + display: this.state.loading ? 'block' : 'none' + }; + + return loadingStyle; + }; + renderThumbnail() { return (