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

Do not trigger slideChange on the initial render. #24717

Merged
merged 2 commits into from Sep 25, 2019

Conversation

sparhami
Copy link

@sparhami sparhami commented Sep 24, 2019

  • Change the carousel implementation to stop notifying when the internal index did not actually change. Note that the initial change is from NaN to an actual index, so that will still notify.
  • Change the carousel 0.2 code to only fire the slideChange event/action after the first one (from the initial render).

Closes #24706
Fixes #24701

Copy link
Contributor

@wassgha wassgha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit confused as to why triggering the event on the initial render is what's causing the error in the issue. Could you clarify that?

* avoid triggering a slideChange on the initial render.
* @private {boolean}
*/
this.skipNextSlideChange_ = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not possible to use the check that currentIndex_ is null instead of adding an instance variable here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, made the change and also fixed #24701 in the process.

@sparhami
Copy link
Author

A bit confused as to why triggering the event on the initial render is what's causing the error in the issue. Could you clarify that?

The problem is that on initial render, we trigger the slideChange with low trust (since the user did not interact) and we do not want it to be used for setState and such, since that could cause the page to jump.

As a result, the code that runs the action complains that you are trying to do a high trust required action with a low trust source.

@sparhami sparhami merged commit e3de090 into ampproject:master Sep 25, 2019
@sparhami sparhami deleted the carousel_initial_slidechange branch September 25, 2019 17:08
@rcebulko
Copy link
Contributor

rcebulko commented Sep 25, 2019

@wassgha @sparhami I noticed this PR was submitted without owners approval. Should the OWNERS.yaml file in amp-carousel be updated/altered, and should an OWNERS.yaml file be added to amp-base-carousel?

For reference, see the current owners tree

@sparhami
Copy link
Author

@wassgha @sparhami I noticed this PR was submitted without owners approval. Should the OWNERS.yaml file in amp-carousel be updated/altered, and should an OWNERS.yaml file be added to amp-base-carousel?

For reference, see the current owners tree

I created #24739 to update the relevant owners.

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