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

Anchor element children click target area. #21

Closed
jackeown opened this issue Jul 21, 2015 · 13 comments
Closed

Anchor element children click target area. #21

jackeown opened this issue Jul 21, 2015 · 13 comments
Assignees

Comments

@jackeown
Copy link

This issue is really annoying me. A menu with links is a fairly common use case and as such I hope this gets fixed soon. I'm just posting a link to the issue on the old repo so you guys are aware that it's still not fixed.

googlearchive/paper-item#14

@craftgear
Copy link

I found a workaround on paper-menu issues.

googlearchive/paper-menu#22 (comment)

On the Stackoverflow post a user named sensor shows how to use 'on-tap' to detect tappings/clickings.

So the following code would mitigate the pain a bit.

  <paper-menu>
    <paper-item on-tap="onSelect"><a href="/">TOP</a></paper-item>
  </paper-menu>

  <script>
    Polymer({
      onSelect: function(e){
        var link = e.currentTarget.querySelector('a');
        if(link) {
         link.click();
       }
      }
    });
  </script>

But honestly, this is ugly.
It destorys the beauty of "There is always an element."

And I can't understand why Polymer dev team doesn't include paper-item with a tags in any demos whatoever.

Maybe they tried it and know it doesn't work so avoid using them together? idk.

@Miliooo
Copy link

Miliooo commented Oct 8, 2015

I ran into the same problem, this is really holding me back...

@craftgear
Copy link

@Miliooo I'd like to recommend you to look at Riot.JS + Material Design Lite.
IMHO, it's much more productive and pragmatic at this point of time.

Though I think I still keep watching how Polymer evolves.

@rubenstolk
Copy link
Contributor

In general this issue is big, any element within paper-item cannot have their own on-tap listeners, simply overruled by the focus event of the paper-item or whatever.

@notwaldorf notwaldorf self-assigned this Oct 26, 2015
@mcarey1590
Copy link

I have found this is due to the absolute position applied to the :before of paper-item that gives the focused/selected visual background. One way to solve this is to override the positioning using the mixin --paper-item-focused-before. A proper fix needs to be put into place though.

@ronnyroeller
Copy link

+1

1 similar comment
@morficus
Copy link

+1

@bicknellr
Copy link
Contributor

Why not just wrap the paper-item with the link? (demo)

@abdonrd
Copy link
Member

abdonrd commented Jan 7, 2016

Similar discussion here: PolymerElements/paper-button#35 (comment).

@eximius313
Copy link

+1

@Nemo64
Copy link

Nemo64 commented Jan 28, 2016

Why is it, that all these paper item/button etc elements can't just receive a href as an attribute. It would make everything so much easier. Allows correct coloring inside the element etc.

@eximius313
Copy link

yup, would be great...

@MarcMouallem
Copy link

MarcMouallem commented Apr 11, 2017

If it helps anyone I am doing something like this to at least get the styling to work.

/* HACK: Makes <a> work with <paper-item> selected item styling.
 * https://github.com/PolymerElements/iron-elements/issues/37*/
a.iron-selected paper-item,
a.iron-selected paper-icon-item{
  font-weight: bold;
}
/* HACK: Makes <a> work with <paper-item> selected item styling.
 * https://github.com/PolymerElements/iron-elements/issues/37*/
a:focus {
  outline: none;
}
/* HACK: Makes <a> work with <paper-item> focus styling.
 * https://github.com/PolymerElements/iron-elements/issues/37 */
a:focus paper-item:before,
a:focus paper-icon-item:before {
  @apply(--layout-fit);
  background: currentColor;
  content: '';
  opacity: var(--dark-divider-opacity);
}

P.S. <a> must wrap <paper-item> and not the other way around so that the entire item, including any icons, is part of the "hit" area. Also, implementing the same functionality imperatively would cause the app to lose out on all the cool browser anchor tag features such as open in new tab.

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

No branches or pull requests