thoughtbot / refills

[no longer maintained]
http://refills.bourbon.io
MIT License
1.5k stars 148 forks source link

2.0 dropdown doesn't support anything but text in button #438

Closed sgatz closed 7 years ago

sgatz commented 7 years ago

The dropdown here: http://refills.netlify.com/

uses target.event to determine when to open the dropdown. That means if you add an image (or any other html tag) within the to-be-clicked item, it won't open. The target.event gives what was actually clicked on, not the item that was meant to be the opening event.

Even in your example page, try clicking on the little down arrow - it won't open since target.event is getting the span.

non-working example:

<a href="#" data-dropdown="toggle"
          aria-haspopup="true"
          aria-expanded="false"
          aria-controls="example-dropdown">
    <img src="foo.gif">
 </a>

this works, but for only the text not in a span

<a href="#" data-dropdown="toggle"
          aria-haspopup="true"
          aria-expanded="false"
          aria-controls="example-dropdown">
    I am text not in another html element and work <span>I won't work</span>
 </a>

The JS probably needs to be moved to use $(this), but I'm having problems trying to make it work myself (it's a little above my skill level).

creuter commented 7 years ago

@sgatz thanks! Does https://github.com/thoughtbot/refills/pull/439 take care of this for you? Those changes are updated on http://refills.netlify.com/#dropdown-snippets

sgatz commented 7 years ago

@creuter Yep, that totally did the trick! thanks for the fix.