Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facebook Embed Block preview error doesn't differentiate from a oEmbed API error #8361

Closed
7studio opened this issue Aug 1, 2018 · 11 comments
Labels
[Block] Embed Affects the Embed Block [Feature] Blocks Overall functionality of blocks Needs Copy Review Needs review of user-facing copy (language, phrasing) [Type] Enhancement A suggestion for improvement.

Comments

@7studio
Copy link

7studio commented Aug 1, 2018

Describe the bug
When I try to use the Embed Blocks, the preview of a valid embeddable content and the error message for an invalid URL have the same render.

To Reproduce
Steps to reproduce the behaviour:

  1. Create a new content.
  2. Add a Facebook Embed Block.
  3. Paste a valid content URL. E.g.: https://www.facebook.com/oohmyworld/videos/2324195200940031/
  4. See the error message "Previews for this are unavailable in the editor, sorry!".
  5. Add a Facebook Embed Block.
  6. Paste an invalid content URL. E.g.: https://www.facebook.com/oohmyworld/vides/2324195200940031/
  7. See the error message "Previews for this are unavailable in the editor, sorry!".

Expected behaviour
Gutenberg should display different error messages for failed previews and failed oEmbed API requests.
E.g.:

  • Failed preview: "Previews for this are unavailable in the editor, sorry!"
  • oEmbed API error: "This content URL is invalid, sorry!"

Screenshots

Edition:

Previews for Embeddable Facebook Content
Previews for Embeddable Facebook Content

Website:

Previews for Embeddable Facebook Content
Previews for Embeddable Facebook Content

@danielbachhuber danielbachhuber added [Type] Enhancement A suggestion for improvement. REST API Interaction Related to REST API [Feature] Blocks Overall functionality of blocks Needs Copy Review Needs review of user-facing copy (language, phrasing) labels Aug 1, 2018
@danielbachhuber
Copy link
Member

Thanks for the report, @7studio

Gutenberg should display different error messages for failed previews and failed oEmbed API requests.

Notably, Facebook previews don't ever work in Gutenberg (introduced in f9d17bc and #816). The message "Previews for this are unavailable in the editor, sorry!" is always true because Gutenberg never attempts to fetch the oEmbed preview.

Flagging as Needs Copy Review because I think a little bit of wordsmithing could help the user understand why their Facebook embeds are behaving this way.

@danielbachhuber danielbachhuber changed the title Embeds Blocks don't differentiate a preview error from a oEmbed API error Facebook Embed Block preview error doesn't differentiate from a oEmbed API error Aug 1, 2018
@danielbachhuber
Copy link
Member

Another idea, and this would be a refinement to the existing implementation, would be to attempt the oEmbed preview, and then have the preview message distinguish between a Facebook Embed that would preview on the frontend vs. one that wouldn't (because the URL is incorrect, etc.)

@michelleweber
Copy link

why their Facebook embeds are behaving this way

Why do they -- what detail do you want to communicate here? And there's nothing the user can do about this, right?

@danielbachhuber
Copy link
Member

Why do they -- what detail do you want to communicate here?

Facebook Embeds don't preview in Gutenberg like, for instance, Twitter Embeds do.

And there's nothing the user can do about this, right?

Correct.

@7studio
Copy link
Author

7studio commented Aug 2, 2018

Thank you to take into account this issue @danielbachhuber

The message "Previews for this are unavailable in the editor, sorry!" is always true because Gutenberg never attempts to fetch the oEmbed preview.

When I used the word "preview" I wanted to say "the oEmbed content displayed" sorry for this misspelling. So in my case, the current Gutenberg message is wrong because WordPress succeeds in catching the response of oEmbed API but Gutenberg doesn't render it 😉

I hope Facebook embeds can have the same behaviour than Twitter in the near future 😁

@michelleweber
Copy link

So in the interest of giving the user a useful next step/solution, I'm thinking you want something like:

Unlike other embeddable content, embedded Facebook links don't preview in the editor. Take a look at the page preview to see how they look.

@7studio
Copy link
Author

7studio commented Aug 3, 2018

Not really 😅

First of all, I didn't understand why @danielbachhuber said

Notably, Facebook previews don't ever work in Gutenberg

I took the time to look into core-blocks/embed and the Sandbox component and now I understand why Facebook contents can't be included for the moment.

I will try to argument a solution in my other issue #8360

IMHO, a message like:

Unlike other embeddable content, embedded Facebook links don't preview in the editor. Take a look at the page preview to see how they look.

is the worst thing that Gutenberg can do. I don't want to switch into preview mode to know if you paste a wrong URL… Facebook contents should not be an exception.

Due to an error in my code (/oembed/1.0/proxy/ route returned a malformatted JSON), it seems that Gutenberg is already able to display the suitable message for a wrong URL:

Previews for Embeddable Facebook Content

Gutenberg could take into account the WP_Error from the REST route response in gutenberg_filter_oembed_result to display the message above.

Example of WP_Error for wrong URL:

WP_Error Object
(
    [errors] => Array
        (
            [oembed_invalid_url] => Array
                (
                    [0] => Not Found
                )
        )
    [error_data] => Array
        (
            [oembed_invalid_url] => Array
                (
                    [status] => 404
                )
        )
)

Currently, Gutenberg returns this JSON for my invalid URL:

{
'html': '<a href="https://www.facebook.com/oohmyworld/vidos/2324195200940031/">https://www.facebook.com/oohmyworld/vidos/2324195200940031/</a>',
'provider_name': 'Embed Handler'
}

If Gutenberg doesn't return html entry, it could pass into this condition core-blocks/embed/index.js#L207 and display the appropriate message 😉

In fact, this behaviour could be applied for all services 😍

@danielbachhuber
Copy link
Member

@7studio Do you want to open a pull request for the behavior you'd prefer?

@7studio
Copy link
Author

7studio commented Aug 7, 2018

@danielbachhuber Yes, I will ☺️ Thank you to take into account this issue.

@notnownikki notnownikki added the [Block] Embed Affects the Embed Block label Oct 4, 2018
@danielbachhuber danielbachhuber added this to the WordPress 5.0 milestone Oct 18, 2018
@danielbachhuber danielbachhuber removed the REST API Interaction Related to REST API label Oct 18, 2018
@danielbachhuber
Copy link
Member

Removing the REST API Interaction label because this doesn't need any changes from the REST API.

@notnownikki
Copy link
Member

This was fixed by #10958 where we separated the preview and input components so that the logic isn't mixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Embed Affects the Embed Block [Feature] Blocks Overall functionality of blocks Needs Copy Review Needs review of user-facing copy (language, phrasing) [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

4 participants