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

fix(page): teach page.click() to click partially offscreen buttons #2806

Merged
merged 2 commits into from
Jun 27, 2018

Conversation

aslushnikov
Copy link
Contributor

Originally, we use Element.scrollIntoViewIfNeeded to make sure
button is on screen before trying to click it.

However, Element.scrollIntoViewIfNeeded doesn't work in certain
scenarios, e.g. when element is partially visible and horizontal
scrolling is required to make it fully visible.

This patch polyfills element.scrollIntoViewIfNeeded using
IntersectionObserver and Element.scrollIntoView.

Fixes #2804.

Originally, we use `Element.scrollIntoViewIfNeeded` to make sure
button is on screen before trying to click it.

However, `Element.scrollIntoViewIfNeeded` doesn't work in certain
scenarios, e.g. when element is partially visible and horizontal
scrolling is required to make it fully visible.

This patch polyfills `element.scrollIntoViewIfNeeded` using
IntersectionObserver and `Element.scrollIntoView`.

Fixes puppeteer#2804.
});
observer.observe(element);
});
if (Math.abs(visibleRatio - 1.0) > 1e-3)
Copy link
Collaborator

Choose a reason for hiding this comment

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

1e-3 is scary. Lets just compare to 1

@aslushnikov aslushnikov merged commit f55d005 into puppeteer:master Jun 27, 2018
@transitive-bullshit
Copy link

Just wanted to say that it's an amazing feeling to run into an issue, track it down, and find out it's already been solved!

Keep up the great work, guys!! @aslushnikov @JoelEinbinder 💯

@aslushnikov aslushnikov deleted the fix-clicking branch August 1, 2018 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants