🚀 [Page Attachments] Ensure that the page attachment container is not inadvertently rendered by the AMP Resources manager#37961
Conversation
…hide the element the first time the user starts dragging the attachment open
|
Hey @gmajoulet, @newmuis, @mszylkowski! These files were changed: |
extensions/amp-story-page-attachment/0.1/amp-story-draggable-drawer.js
Outdated
Show resolved
Hide resolved
extensions/amp-story-page-attachment/0.1/amp-story-page-attachment.js
Outdated
Show resolved
Hide resolved
extensions/amp-story-page-attachment/0.1/amp-story-draggable-drawer.js
Outdated
Show resolved
Hide resolved
gmajoulet
left a comment
There was a problem hiding this comment.
This code claims ownership over the lifecycle of all AMP elements within it. My guess is that the code runs AFTER AMP has already built images, which is why they load.
A few fixes are possible:
- Use CSS to hide the attachment content till layoutCallback ran. If the content is hidden, AMP will not build it
- Same but use JS to do so (hidden by default with CSS, made visible AFTER we claim ownership)
…en the attachment's owner has been set to itself
I've taken the 2nd approach and I've updated the code, description, and title to reflect this |
extensions/amp-story-page-attachment/0.1/amp-story-draggable-drawer.js
Outdated
Show resolved
Hide resolved
|
cc @processprocess to help test all draggable-drawer uses |
I've tested attachments that contain a mix of images and text, on both desktop and mobile. I'll also check any other cases that we deem necessary |
Thanks for manually testing these @coreymasanto :) @gmajoulet Our drawer visual diff tests open the attachment, which should cover this but agree it's good to manually test as well: |
mszylkowski
left a comment
There was a problem hiding this comment.
Looks good, make sure the network tab shows the images loading later as expected and 🚢
The existing
setOwner()call ensures that the page attachment manages its own resources instead of them being handled by the AMP Resources manager. However, it's likely that this call is running after AMP has already loaded the contents of the attachment. This PR hides the attachment container by default, which ensures that its content is not inadvertently rendered/loaded too early. The end result is that page attachment images remain unloaded until thescheduleLayout()call when the attachment fully opens.