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

Bento: components fail to hide placeholder content once loaded #34616

Closed
westonruter opened this issue May 30, 2021 · 5 comments · Fixed by #35788
Closed

Bento: components fail to hide placeholder content once loaded #34616

westonruter opened this issue May 30, 2021 · 5 comments · Fixed by #35788

Comments

@westonruter
Copy link
Member

Description

When using amp-twitter 1.0 (Bento) with placeholder content as follows:

<amp-twitter width="600" height="480" layout="responsive" data-tweetid="1397995435386679302" class="twitter-tweet" data-width="550" data-dnt="true">
  <blockquote class="twitter-tweet" data-width="550" data-dnt="true" placeholder="">
    <p lang="en" dir="ltr">
      ⛺🔥
      Fun fact: cAMPfire stories are the best stories.<br>
      <a href="https://twitter.com/CrystalOnScript?ref_src=twsrc%5Etfw">@CrystalOnScript</a>,
      <a href="https://twitter.com/nainar92?ref_src=twsrc%5Etfw">@nainar92</a>, and Caroline Liu gather around to
      unbox the Bento developer preview, which allows you to use AMP ⚡
      components everywhere!<br> <br>
      📺
      Tune in → <a href="https://t.co/RViEFP4AR9">https://t.co/RViEFP4AR9</a> <a href="https://t.co/Ni8B5VNZVz">pic.twitter.com/Ni8B5VNZVz</a>
    </p>
    — AMP Project (@AMPhtml) <a href="https://twitter.com/AMPhtml/status/1397995435386679302?ref_src=twsrc%5Etfw">May
    27, 2021</a>
  </blockquote>
</amp-twitter>

The placeholder content fails to be hidden when the component initializes, causing overlapping text:

image

See example on playground.

Reproduction Steps

Add amp-twitter 1.0 with placeholder content.

Relevant Logs

No response

Browser(s) Affected

No response

OS(s) Affected

No response

Device(s) Affected

No response

AMP Version Affected

2105150310000

@westonruter
Copy link
Member Author

While #35788 addresses the issue for amp-twitter, it appears to have done so for that component exclusively. It turns out that other Bento components also have the issue with placeholder content not being hidden when the component loads. See amp-youtube for example on AMP Playground.

@westonruter westonruter reopened this Aug 25, 2021
@westonruter westonruter changed the title Bento: amp-twitter fails to hide placeholder content Bento: components fail to hide placeholder content once loaded Aug 25, 2021
@kvchari kvchari self-assigned this Aug 26, 2021
@caroqliu
Copy link
Contributor

While #35788 addresses the issue for amp-twitter, it appears to have done so for that component exclusively. It turns out that other Bento components also have the issue with placeholder content not being hidden when the component loads. See amp-youtube for example on AMP Playground.

Good call. I would recommend providing roughly three callbacks:

  • onLoading - to show the loader if available
  • onLoad or onReady - to remove placeholder/loader
  • onError - to show fallback or placeholder

We can use amp-twitter as an example for onLoad and amp-render as an example for onError and onLoading:

'onLoading': () => {
this.toggleLoading(true);
},

'onError': () => {
this.toggleLoading(false);
// If the content fails to load and there's a fallback element, display the fallback.
// Otherwise, continue displaying the placeholder.
if (this.getFallback()) {
this.togglePlaceholder(false);
this.toggleFallback(true);
} else {
this.togglePlaceholder(true);
}
},

@kvchari
Copy link
Contributor

kvchari commented Aug 26, 2021

working on a fix for this here: #35821

@samouri
Copy link
Member

samouri commented Sep 7, 2021

@kvchari: now that #35821 has merged, can this be closed?

@kvchari
Copy link
Contributor

kvchari commented Sep 8, 2021

@samouri yes this should be closed. Going forward, all bento components with dynamic content will need to invoke the callbacks provided in BaseElement (onLoading/onLoad/onError) to ensure each component supports placeholders properly

@kvchari kvchari closed this as completed Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants