amp-google-doc-embed fails to display multiple documents
See original GitHub issueDescription
This page is valid: https://afdsi.com/__amp-issues/_google-doc-embed/
It uses amp-google-doc-embed
to feature PDFs, Google Sheets, and Word (docx) files.
However, only the first instance of amp-google-doc-embed
works.
All document types work, but only when assigned to the first tab.
Are we doing something wrong, or can only one instance of amp-google-doc-embed be displayed on a page?
Reproduction Steps
https://afdsi.com/__amp-issues/_google-doc-embed/
Browser(s) Affected
Chrome, Firefox
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
amp-google-document-embed
The amp-google-document-embed component displays document files like Word documents, Excel spreadsheets, and PDFs. Example: <amp-google-document-embed ...
Read more >amphtml/amp-google-document-embed.md at main - GitHub
The amp-google-document-embed component displays document files like Word documents, Excel spreadsheets, and PDFs. Example: <amp-google-document-embed ...
Read more >Display bug when embedding multiple Google Docs wi...
When I embed multiple Google Docs under separated {expand} macros, only the first embedded document that you click to expand will display.
Read more >Embedding with Google AMP - Overview - Embedly
From the amp-frame docs: `amp-iframe` may not appear close to the top of the document (except for iframes that use placeholder as described...
Read more >Embeds in Google AMP pages - Audioboom
Google AMP will refuse to load iframes near the top of the page, unless the iframe has a placeholder. (From the docs: "They...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
First, we have a requirement that things that are
display: none
do not cause a layout. This is easiest to understand when discussing Ads: if an ad cannot be seen, we cannot make a network request to fill the ad slot. This is both a resource win (less network/CPU usage), and a privacy win.So, when doing initial detection on the document, we record whether an element is displayable. Ideally, when an element becomes displayed, we want to trigger layout. But it’s extremely difficult to detect changes in
display: none
, because there’s no Observer in JS that will tell us when computed styles change.We do have a
MutationObserver
that listens to changes to thehidden
attribute, which is our approved way to handle this. We can cause mutations ofhidden
viaamp-bind
, or anon="tap:el.hide
handler on the checkboxes.I was able to get this example working by adding
on=tap:sectionN.show
to each of the<input>
elements. See here.The
.show
action is a workaround to force the Runtime to remeasure the element and trigger a layout if required.