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

Hover event not triggered when hovering over inner HTML element #23

Open
sjieg opened this issue Sep 13, 2021 · 0 comments
Open

Hover event not triggered when hovering over inner HTML element #23

sjieg opened this issue Sep 13, 2021 · 0 comments

Comments

@sjieg
Copy link

sjieg commented Sep 13, 2021

Hello, first off, thanks for this plug-in. It's a great help getting some font awesome icons inside drop-downs.

When a HTML element inside the dropdown is 100% of the height of the option, the hover event is not triggered due to the following piece of code in hoverDropdownItem:

e.target.nodeName !== 'LI'

From your example, I've added .glyphicon{height: 48}

<label for="spell">With prefix/suffix:</label><br>
<select id="spell" name="spell" title="Select your spell">
  <option data-prefix="<span aria-hidden='true' class='glyphicon glyphicon-eye-open'></span>" data-suffix="<small>petrification</small>">Eye of Medusa</option>
  <option data-prefix="<span aria-hidden='true' class='glyphicon glyphicon-fire'></span>" data-suffix="<small>area damage</small>">Rain of Fire</option>
</select>
<script>
$(document).ready(function() {
  // Initiate Pretty Dropdowns
  $('#spell').prettyDropdown({
    afterLoad: function() {
      console.log('Spells are ready!');
    }
  });
});
</script>
<style>
.glyphicon{height: 48}
</style>

image

When using the dropdown, and hovering over the icons, the hover event won't trigger.

I've solved this on changing:

if (e.target.nodeName!=='LI' || !$dropdown.hasClass('active') || new Date()-$dropdown.data('lastKeypress')<200) return;

To

let target = (e.target.nodeName !== 'LI') ? e.target.parent('li') : e.target
if (target !== 'LI' || !$dropdown.hasClass('active') || new Date() - $dropdown.data('lastKeypress') < 200) return;

I'm not sure why you're checking of the target is a li, but I thought to keep it in not to break anything new :)

sjieg added a commit to sjieg/pretty-dropdowns that referenced this issue Sep 13, 2021
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

No branches or pull requests

1 participant