AngularStrap bs-dropdown with the “hover” trigger doesn't stay open long enough

允我心安 提交于 2019-12-12 13:22:55

问题


When using the bs-dropdown with the "hover" trigger, the menu doesn't stay visible long enough to allow the user to click on a menu item:

http://plnkr.co/edit/Fi39BdCOqHXnPAgITD01?p=preview

Using a delay makes it behave in unexpected ways:

http://plnkr.co/edit/Y2Q63DDJEyP9CTPMUfYD?p=preview

Ideally the dropdown should stay up as long as the mouse is on the menu, and disappear when the mouse leaves the menu.


回答1:


That is because hover pseudoevent's mouseleave gets triggered when you hover out of the button to focus on the actual dropdown. Instead you can try providing the container as button itself. Example

<button type="button" 
        class="btn btn-lg btn-primary myButton" 
        bs-dropdown="dropdown" 
        data-container=".myButton">Hover to toggle dropdown</button>

Here i added data-container as myButton which is the class i gave for the same button.

Plnkr

Using delay on hide is of no effect since the hide will eventually happen after the specified delay as the animation gets queued, as you hover out of the button and is going to hide after the delay so you should expect the user to be quick enough to select the dropdown option. But as a work around you can just use container till there is a fix provided for this.




回答2:


See this issue for tracking the progress of this issue:

bs-dropdown and trigger hover #638




回答3:


I am trying to implement a dropdown on a bootstrapped nav bar. After reading the linked github issue in Blade1336's response I added data-container="self". This did make the dropdown visible long enough to click on the dropdown items. Unfortunately, after adding it the menu dropdown items were no longer clickable. data-container="self" also resulted in a slightly wonky ui experience. My code looked like this:

<li data-match-route="/config*">  
   <a bs-dropdown="configDropdown" data-trigger="hover" data-container="self">Config</a>
</li>

I ended up switching around the tags and placing the bs-dropdown in my <li> tag instead which gave me the desired functionality (my links are clickable again). My code now looks like this:

<li data-match-route="/config*" bs-dropdown="configDropdown" data-trigger="hover" data-container="self">
   <a>Config</a>
</li>

*I kept the <a> tag just for styling purposes



来源:https://stackoverflow.com/questions/21282900/angularstrap-bs-dropdown-with-the-hover-trigger-doesnt-stay-open-long-enough

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!