amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

'hidden-mutation-observer' breaks amp-lightbox

Open zhang-90 opened this issue 8 years ago • 12 comments

bug

  • when close amp-lightbox with close event can not really close it if the amp-lightbox have position: fixed

reproduce

  1. open detail page

  2. click Free Ship image

  3. click Ship To image

  4. and close it image

  5. Page gets stuck. It has no effect no matter where you click.

analysis

  • image
  • because the amp-lightbox have position: fixed, so when you click and trigger close event the amp-lightbox not really close, it is just opacity set to 0

What browsers are affected?

  • all browsers, ios and android

version

  • Powered by AMP ⚡ HTML – Version 1811012008580

zhang-90 avatar Nov 05 '18 11:11 zhang-90

Looks like transitionend or animationend events are not triggered by setting the closedStyle, which means this collapse callback is never called. Not sure why yet.

Doesn't repro on the ABE example which also uses the amp-lightbox.close action.

dreamofabear avatar Nov 05 '18 14:11 dreamofabear

please try with the sample here : https://github.com/aemsite/ampdemo/blob/master/cant-close-lightbox.html

Basically when the lightbox is styled with position:fixed, then when users trigger lightbox.close actions, the [hidden] will not be appended to the lightbox anymore.

leonahliang90 avatar Nov 05 '18 15:11 leonahliang90

Yea, probably related to fixed-layer. Looks like the problematic lightbox is being tracked by FixedLayer per its i-amphtml-fixedid:

<amp-lightbox id="country-lb" 
    class="float-wrap i-amphtml-element i-amphtml-layout-nodisplay i-amphtml-overlay i-amphtml-scrollable i-amphtml-layout" 
    layout="nodisplay" 
    scrollable="" 
    i-amphtml-fixedid="F10" 
    style="opacity: 0; top: calc(0px);">

@leonalicious Adding position: fixed and top and bottom CSS is redundant since amp-lightbox already has it: https://github.com/ampproject/amphtml/blob/78e80f1ac5de8ed96d529e54db2da4a064ebb94b/extensions/amp-lightbox/0.1/amp-lightbox.css#L16-L24

dreamofabear avatar Nov 05 '18 15:11 dreamofabear

transitionend and animationend events are not triggered because FixedLayer sets transition: none: https://github.com/ampproject/amphtml/blob/78e80f1ac5de8ed96d529e54db2da4a064ebb94b/src/service/fixed-layer.js#L378-L382

This only became a problem after #18797. The mutation observer causes the unsetting of transition after the amp-lightbox has its hidden attribute removed during opening.

dreamofabear avatar Nov 05 '18 15:11 dreamofabear

Disabling hidden-mutation-observer experiment fixes this, which is an easy and low-risk cherry-pick. @cvializ

One idea to roll-forward is to avoid tracking AMP elements that are known to be fixed-position e.g. amp-lightbox, amp-image-lightbox, etc. A simple early-return in FixedLayer.setupElement_ appears to work.

dreamofabear avatar Nov 05 '18 15:11 dreamofabear

The issue is not with hidden-mutation-observer, but the experiment surfaced it. This can still happen if a fixed-layer update happens in between the close action and when the transition actually finishes.

jridgewell avatar Nov 05 '18 18:11 jridgewell

True but when do fixed-layer updates trigger without the mutation observer? AFAICT only on init and a few special cases (viewer, amp-live-list).

dreamofabear avatar Nov 05 '18 19:11 dreamofabear

This is fixed in version 1811051833450.

#19149 tracks the follow-up work that will allow hidden-mutation-observer to roll forward.

dreamofabear avatar Nov 06 '18 05:11 dreamofabear

hey, thank you for the prompt fixed , but just FYI, we have tested, it is working fine on Android and iOS safari, but not on iOS Chrome, we are still looking at it...

leonahliang90 avatar Nov 06 '18 05:11 leonahliang90

Hmm, works fine for me on iOS Chrome 72 on iOS 12.

dreamofabear avatar Nov 06 '18 05:11 dreamofabear

hey, thank you for the prompt fixed , but just FYI, we have tested, it is working fine on Android and iOS safari, but not on iOS Chrome, we are still looking at it...

I think that's a new issue. This time, when you click the close button on the top left corner of the shipping-to country list, the page is not stuck, but you will be brought back to the product list page.

Hanrui avatar Nov 06 '18 05:11 Hanrui

here you go with the UA of Chrome on iOS:

Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/70.0.3538.75 Mobile/15E148 Safari/605.1

hope it helps.

leonahliang90 avatar Nov 06 '18 12:11 leonahliang90