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

🐛 amp-story-page-outlink CTA is broken in localDev #35914

Closed
jshamble opened this issue Sep 1, 2021 · 6 comments
Closed

🐛 amp-story-page-outlink CTA is broken in localDev #35914

jshamble opened this issue Sep 1, 2021 · 6 comments
Assignees

Comments

@jshamble
Copy link
Contributor

jshamble commented Sep 1, 2021

Description

Swipe/click doesn't work for <amp-story-page-outlink> on localDev server.

TypeError: Cannot read property 'querySelector' of null
    at programaticallyClickOnTarget2 (amp-story-page-attachment.js:346)
    at amp-story-page-attachment.js:362
    at wrapped2 (timer-impl.js:70)
reportError @ error-reporting.js:203
wrapped2 @ timer-impl.js:72
setTimeout (async)
delay @ timer-impl.js:76
openRemote_ @ amp-story-page-attachment.js:361
open @ amp-story-page-attachment.js:325
onSwipeY_ @ amp-story-draggable-drawer.js:448
onTouchMove_ @ amp-story-draggable-drawer.js:342
wrapped2 @ event-helper-listen.js:49

Reproduction Steps

Go to a demo examples/amp-story/attachment.html and swipe or click on one of the amp-story-page-outlink pages' cta

Relevant Logs

No response

Browser(s) Affected

All

OS(s) Affected

All

Device(s) Affected

All

AMP Version Affected

No response

@jshamble
Copy link
Contributor Author

jshamble commented Sep 1, 2021

#35913 fixes this.

@jshamble jshamble closed this as completed Sep 1, 2021
@calebcordry
Copy link
Member

Upon further investigation we found this is another side effect of #35823

<amp-story-outlink> creates a button in shadow DOM by calling createShadowRootWithStyle. createShadowRootWithStyle will not create shadow dom if getMode().test === true

export function createShadowRootWithStyle(container, element, css) {
const style = self.document.createElement('style');
style./*OK*/ textContent = css;
const containerToUse = getMode().test
? container
: createShadowRoot(container);
containerToUse.appendChild(style);
containerToUse.appendChild(element);
}

Later we try to queryselect explicitly into the shadow root using .shadowRoot but this does not exist because createShadowRootWithStyle did not create the shadow dom.

const pageAttachmentChild = this.element.parentElement
?.querySelector('.i-amphtml-story-page-open-attachment-host')
.shadowRoot.querySelector('a.i-amphtml-story-page-open-attachment');

@calebcordry calebcordry reopened this Sep 1, 2021
@calebcordry calebcordry changed the title Amp story page attachment is null and doesn't link to another page with page-outlink swipe up gesture. 🐛 amp-story-page-outlink CTA is broken Sep 1, 2021
@calebcordry
Copy link
Member

@samouri cc/ @ampproject/wg-stories

@calebcordry calebcordry changed the title 🐛 amp-story-page-outlink CTA is broken 🐛 amp-story-page-outlink CTA is broken in localDev Sep 1, 2021
@samouri samouri self-assigned this Sep 7, 2021
@gmajoulet
Copy link
Contributor

Can this be closed?

@samouri
Copy link
Member

samouri commented Sep 9, 2021

I'll ensure this does not occur again when trying to redeploy the change

@joydeep-bhowmik
Copy link

joydeep-bhowmik commented Apr 15, 2023

To the people who are looking for a fix , read this.
Tag 'amp-story-page-outlink', if present, must be the last child of tag 'amp-story-page'.

example

                  <amp-story-page id="idaxar440">
                     <amp-story-grid-layer template="fill">
                        <amp-img src="uploads/image.png>"
                           width="720" height="1280"
                           layout="responsive">
                        </amp-img>
                     </amp-story-grid-layer>
                     <amp-story-grid-layer template="thirds">
                        <div class="text" grid-area="lower-third">
                           <h1>hello</h1>
                        </div>
                     </amp-story-grid-layer>
                        <amp-story-page-outlink layout="nodisplay">
                              <a href="link" title="swipe up"></a>
                        </amp-story-page-outlink>
                  </amp-story-page>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants