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

[BUG] Page.click() doesn't work when pointer-events: none is toggled off #2175

Closed
celeryclub opened this issue May 10, 2020 · 2 comments · Fixed by #2217
Closed

[BUG] Page.click() doesn't work when pointer-events: none is toggled off #2175

celeryclub opened this issue May 10, 2020 · 2 comments · Fixed by #2217
Assignees

Comments

@celeryclub
Copy link
Contributor

Context:

  • Playwright Version: 1.0.1
  • Operating System: macOS
  • Node version: 12.16
  • Browser: Chromium

Code Snippet

const { chromium } = require('playwright-chromium');

(async () => {
  const browser = await chromium.launch({
    headless: false,
    args: ['--window-size=1280,720'],
  });
  const page = await browser.newPage();

  await page.goto('https://f1t94.csb.app/', { waitUntil: 'networkidle' });
  await page.click('.button');
  await page.waitForTimeout(1000);

  // We should be on bing.com right now but we're still on the original page because the click didn't work

  await browser.close();
})();

Describe the bug

Hey team. Hope all is well and you had a great weekend.

I have a page with a button that's not clickable until 5s after the page loads. I'd expect playwright to still click the button since this is well within the 30s default timeout, but it doesn't appear to wait for pointer-events to be enabled. It seems like it tries to click it before they're enabled and fails and never tries again.

Here's a link to the code sandbox for easy viewing of the source code. https://codesandbox.io/s/awesome-dijkstra-f1t94?file=/src/App.js

Thanks for taking a look!

@celeryclub celeryclub changed the title [BUG] page.click doesn't work when pointer-events: none is toggled off [BUG] Page.click doesn't work when pointer-events: none is toggled off May 10, 2020
@celeryclub celeryclub changed the title [BUG] Page.click doesn't work when pointer-events: none is toggled off [BUG] Page.click() doesn't work when pointer-events: none is toggled off May 10, 2020
@dgozman dgozman self-assigned this May 13, 2020
@dgozman
Copy link
Contributor

dgozman commented May 13, 2020

Hi Steve. This one sounds like it is catching a real bug on the website. I would think that the real user will try to click on the button, and nothing is going to happen. At least that's what I did myself. Perhaps, in the real app it looks differently? What do you think?

@celeryclub
Copy link
Contributor Author

Thanks for looking into this @dgozman. In the real app, the page is in a loading state and the developer added pointer-events: none to the "Change filter" button until the current loading is finished. There may be a better way to handle this in the app code, since it could be confusing if the load takes a few moments and the user tries to click the button.

So yes, maybe we should change the app code. :) But I just want to double-check - do you consider this a bug in playwright? Is this use case of toggling pointer-events meant to be supported?

aslushnikov added a commit to aslushnikov/playwright that referenced this issue May 13, 2020
While checking for hittarget, we first bubble from a target element
up to find the first element without `pointer-events: none` style.

While doing so, we can bubble all the way up to the parent. In reality,
we should not bubble past meaningful elements, such as:
- `BUTTON`
- `INPUT`
- `A`
- `LABEL`

The list of tags is taken from [Cypress](https://docs.cypress.io/api/commands/contains.html#Preferences)
which applies a similar tactic for their selector processing.

Fixes microsoft#2175
aslushnikov added a commit to aslushnikov/playwright that referenced this issue May 13, 2020
While checking for hittarget, we first bubble from a target element
up to find the first element without `pointer-events: none` style.

While doing so, we can bubble all the way up to the parent. In reality,
we should not bubble past meaningful elements, such as:
- `BUTTON`
- `INPUT`
- `A`

The list of tags is taken from [Cypress](https://docs.cypress.io/api/commands/contains.html#Preferences) which applies a
similar tactic for their selector processing. However, we don't use
`LABEL` as a boundary since we've seen labels inside buttons.

Fixes microsoft#2175
aslushnikov added a commit to aslushnikov/playwright that referenced this issue May 13, 2020
While checking for hittarget, we first bubble from a target element
up to find the first element without `pointer-events: none` style.

While doing so, we can bubble all the way up to the parent. In reality,
we should not bubble past meaningful elements, such as:
- `BUTTON`
- `INPUT`
- `A`

The list of tags is taken from [Cypress](https://docs.cypress.io/api/commands/contains.html#Preferences) which applies a
similar tactic for their selector processing. However, we don't use
`LABEL` as a boundary since we've seen labels inside buttons.

Fixes microsoft#2175
aslushnikov added a commit to aslushnikov/playwright that referenced this issue May 18, 2020
While checking for hittarget, we first bubble from a target element
up to find the first element without `pointer-events: none` style.

This bubbling does not make much sense: we risk desperately clicking
"body" element, when we were actually asked to click some deeply-nested
"span".

Additionally, in many cases the original intent is to click a button. In this
case, we should use the enclosing "button" as a hit target directly.

Fixes microsoft#2175
aslushnikov added a commit that referenced this issue May 19, 2020
While checking for hittarget, we first bubble from a target element
up to find the first element without `pointer-events: none` style.

This bubbling does not make much sense: we risk desperately clicking
"body" element, when we were actually asked to click some deeply-nested
"span".

Additionally, in many cases the original intent is to click a button. In this
case, we should use the enclosing "button" as a hit target directly.

Fixes #2175
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 a pull request may close this issue.

2 participants