W3C home > Mailing lists > Public > public-pointer-events@w3.org > October to December 2017

Re: [pointerevents] Click event while a pointer event is captured

From: freshp86 via GitHub <sysbot+gh@w3.org>
Date: Wed, 06 Dec 2017 01:04:06 +0000
To: public-pointer-events@w3.org
Message-ID: <issue_comment.created-349494814-1512522244-sysbot+gh@w3.org>
Hi everyone. I would like to present a real world use-case from Chromium's codebase which is suffering from the fact that the 'cilck' event is fired on a non-capturing element.

Consider the following element, where a switcher UI control lies within a container row.

Requirements for  this component are:
* Switch can be toggled by clicking on it directly
* Switch can be toggled dragging it towards the desired direction
* Switch can be toggled by clicking on the surrounding box (white in this case).

I created a more minimal [repro example here](https://jsfiddle.net/66h44khn/7/), which I've only tried in Chrome. Please ignore the Polymer code, and just scroll down to the bottom of the JS code (line 163 to the end). 

When the user drags the toggle, then releases the pointer on top of the container box , the 'extraneous' click event, is triggering the container's click handler, which unexpectedly toggles the switch. The hack we've resorted is to cache the last `pointerup` event timeStamp and compare it with the `click` event's timeStamp. If they are the same the event is ignored. Otherwise, this indicates the user clicked directly on the container and the event is handled.

I would like to remove that hack, so trying to restart this conversations on why the current behavior of letting click events fire on non-capture element is useful.
Thank you

GitHub Notification of comment by freshp86
Please view or discuss this issue at https://github.com/w3c/pointerevents/issues/75#issuecomment-349494814 using your GitHub account
Received on Wednesday, 6 December 2017 01:04:24 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 6 December 2017 01:04:25 UTC