PolymerElements / paper-icon-button

A Material Design icon button
https://www.webcomponents.org/element/PolymerElements/paper-icon-button
42 stars 44 forks source link

on-tap event target returning the icon instead of the button #66

Closed ghost closed 8 years ago

ghost commented 8 years ago

If you tap on the button in the center (within the bounds of the icon) it will return the iron-icon element as the target in the returned event.

Expected Outcome

The on-tap event should always return the paper-icon-button element in the target attribute.

Actual Outcome

on-tap events will return the iron-icon element when tapped within the iron-icon bounds. It will return the paper-icon-button element when tapped within the bounds of the button, but outside the bounds of the icon in the button (along the edges). This creates an issue when attempting to have a reliable method of reading the button's id on an on-tap event.

Steps to Reproduce

  1. Put a paper-icon-button element
  2. Give it an id
  3. Set its on-tap event attribute to a function
  4. console.log the value of the function's event.target.id parameter
  5. Depending on the location that the on-tap event occurs it will log either the id given to the button, or icon
e111077 commented 8 years ago

Heya,

It seems as if you are looking for the logical target of the event. Based on our model, we suggest that you use Polymer.dom(event).localTarget to access the paper-icon-button. Here's a JSBin I cooked up to show an example.