amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Possibly removing the '!important' rule from .i-amphtml-layout-size-defined class?

Open wallismith opened this issue 9 years ago • 18 comments

What's the issue?

When using the amp-list component, the added .i-amphtml-layout-size-defined class has a property of overflow: hidden!important;

In order to override this style, I would need to use the !important rule as well, and as a result the AMP page would be invalid.

How do we reproduce the issue?

I have a video showing this issue: https://www.useloom.com/share/f8d91753d79d433cb3dfabeeb0a0e38f

What browsers are affected?

All browsers.

Which AMP version is affected?

Version 1506372648650

wallismith avatar Oct 02 '17 20:10 wallismith

/cc @aghassemi Ali, do you know if there's a workaround for this issue where the footer has a fixed height and cannot accommodate accordions well?

lswang1618 avatar Oct 02 '17 21:10 lswang1618

The root-cause of the problem is that amp-list does not resize if something inside of it changes height. @dvoytenko I am evaluating whether supporting layout=container for amp-list makes sense, I can't think of any issues with supporting it, do you know why container layout has been disallowed?

aghassemi avatar Oct 02 '17 23:10 aghassemi

The overflow:hidden is there explicitly to disallow UX-breaking resizes after the initial render. We typically allow such resizes closer to the bottom of the page, however. But the whole idea of amp-list is that resize is vetoable. E.g. see overflow

Now, that particular use case seems to involve user action. I think we can do something about allowing safer resizes when user action is involved since user action is a good enough indicator that UX will change.

@aghassemi @choumx WDYT?

dvoytenko avatar Oct 03 '17 20:10 dvoytenko

@dvoytenko I was thinking to just allow layout=container for amp-list, I can't find a reason against it, do you know why it was disallowed initially?

aghassemi avatar Oct 03 '17 20:10 aghassemi

Adding a high-trust "resize" action on amp-list seems reasonable. There have been a few related issues: #5686, #9424, #11251

I can't find a reason against it, do you know why it was disallowed initially?

Load page -> scroll past an amp-list -> start reading stuff -> stuff you're reading disappears due to amp-list resize.

dreamofabear avatar Oct 03 '17 20:10 dreamofabear

oh amp-list does attemptChangeHeight, I wrongly thought it is doing changeHeight after render.

aghassemi avatar Oct 03 '17 20:10 aghassemi

Ideally we can automate this, maybe we can capture all click events inside amp-listand rerun the resize logic? this should handle vast majority of cases

aghassemi avatar Oct 03 '17 20:10 aghassemi

Also given setState is high-trust, I assume we can make the second+ loads that are resulted from mutation of src to do force change height?

aghassemi avatar Oct 03 '17 21:10 aghassemi

My preference as well. Here's how I see it.

  1. We catch all click. We do it already anyway, e.g. in Action service.
  2. We mark the click target and/or action target as "user gesture activated" with timestamp.
  3. Whenever we are trying to execute any action with "high trust", e.g. resize, we look if the element is contained inside a container with user gesture activated and unexpected timestamp.

WDYT?

dvoytenko avatar Oct 03 '17 21:10 dvoytenko

I think it makes sense to allow opt-out (or require opt-in) to automatic resizing. Perhaps a new boolean attribute, e.g. <amp-list auto-resize>?

I assume we can make the second+ loads that are resulted from mutation of src to do force change height?

Yep, an example here: https://github.com/ampproject/amphtml/issues/10230#issuecomment-314827209

dreamofabear avatar Oct 03 '17 21:10 dreamofabear

I was hoping user does not need to explicitly trigger resize action on amp-list. e.g. 1- amp-list listens for click inside itself, schedules a check height -> maybe resize task. 2- If src is changed via mutation, it always forces height change (since it assumed src was changed via a high-trust action)

aghassemi avatar Oct 03 '17 21:10 aghassemi

@choumx I vote for opt-out

aghassemi avatar Oct 03 '17 21:10 aghassemi

Opt in/out. Why would an amp-list ever want to opt-out?

dvoytenko avatar Oct 03 '17 21:10 dvoytenko

Opt-in will avoid introducing unexpected UX changes to prod pages.

I imagine most amp-list usages today have static size and an inadvertent tap could cause strange content jumping. E.g. amp-list elements without amp-accordion.

dreamofabear avatar Oct 03 '17 21:10 dreamofabear

Derp, I already suggested this here: https://github.com/ampproject/amphtml/issues/10230#issuecomment-318405678

/cc @ericlindley-g

dreamofabear avatar Oct 03 '17 21:10 dreamofabear

Overall, when users tap, they expect jumps of UI to accommodate whatever they tapped for. So I think opt-out is a bit less of a concern to me.

dvoytenko avatar Oct 03 '17 21:10 dvoytenko

I think not all taps imply user intent. Sometimes I tap when I really mean to start scrolling, or accidentally tap with my palm.

dreamofabear avatar Oct 03 '17 21:10 dreamofabear

De-duping in favor of #10230.

dreamofabear avatar Oct 03 '17 22:10 dreamofabear