bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Popover to remain open when hovering over it

Open boillodmanuel opened this issue 11 years ago • 17 comments

Popover triggered by mouseenter event hide himself as soon as the mouse leave the target element. And it's impossible to click on a link which was in the popover.

I've found some solution in SO which can help for the PR :

  • link to SO: http://stackoverflow.com/questions/20267967/create-hoverable-popover-using-angular-ui-bootstrap
  • direct link to jsfiddle: https://jsfiddle.net/6awhrcec/

And another link with a vanilla js solution: http://jsfiddle.net/WojtekKruszewski/Zf3m7/22/

Could you add this feature?

boillodmanuel avatar Apr 08 '15 17:04 boillodmanuel

The popover-trigger attribute allows you to define which triggers show and hide the popover using the following format:

popover-trigger="showtrigger hidetrigger"

The directive is simply doing the following for you:

element.bind(showtrigger, showTooltipBind)
element.bind(hidetrigger, hideTooltipBind)

The plunker demonstrates using 'mouseenter click' trigger that will leave the popup open during interaction. While this get's us most of the way there, it's not as stable as I would like it to be.

I have been working on a blurNotChildren trigger that will not call the close method until the trigger element or the popup are no longer the document.activeElement. Here is a plunker that demonstrates that approach.

The other ways I've seen of accomplishing this require listeners on several elements and document body click which get's messy to clean up and doesn't necessarily account for a blur event.

RobJacobs avatar Apr 08 '15 19:04 RobJacobs

I'm marking this as Purgatory as I think this sort of custom handling should be left to the user/developer. Instead, we should expose the triggers through a directive controller to allow users to show/hide the tooltip/popovers with their custom handling logic.

If this becomes a high frequency problem, we can consider it further. However, right now, this adds a new feature that isn't there on Bootstrap and I'm worried about bloating this directive with features that most users wouldn't use (and making it buggy and slow).

chrisirhc avatar Apr 13 '15 07:04 chrisirhc

I had a similar issue and addressed it by creating a close delay that I could set through the popover directive (~2000-3000 milliseconds worked well). The problem is that if you attempt to override the fade class that bootstrap provides or attempt to hijack the listeners, things get a little wonky. I have created this feature via PR #3576

tmcgee123 avatar Apr 23 '15 16:04 tmcgee123

@chrisirhc you mentioned exposing the triggers to allow custom handling logic - is that on the roadmap by chance?

erquhart avatar Jun 02 '15 17:06 erquhart

I've made a patch for this at PR https://github.com/angular-ui/bootstrap/pull/3942 adding tooltip-hoverable=true or popover-hoverable=true will enable the feature when triggers.hide is mouseleave

plong0 avatar Jul 13 '15 23:07 plong0

This issue sounds identical to #3855. @wesleycho, I think we can close this.

@boillodmanuel, please see the comments in the referenced issue above for the proper solution.

icfantv avatar Aug 03 '15 05:08 icfantv

Closing as per comments.

wesleycho avatar Aug 03 '15 05:08 wesleycho

I have solved it in a very cleaned way and thought to share it: .popover is being created not as a child of the uib-popover so the idea is to wrap uib-popover with a parent and to control show&hide on hovering the parent. .popover and uib-popover are children of this parent so just left to set popover-trigger=none and you have what you are wishing for.

I created a plunk example: https://plnkr.co/edit/6vzrrH1KUyQeLHDz1hWp?p=preview

odedkeren1 avatar Aug 24 '16 09:08 odedkeren1

Here's another pretty clean way, which doesn't require that the tooltip and the trigger elementactually overlap:

https://plnkr.co/edit/GBjrZiGqXSucPiiXTg0C?p=preview

Essentially, in order to allow the user to "jump" between the elements, we just need to add some sort of grace period (in this case, 500ms) after which we mark the popover as closed.

evenicoulddoit avatar Jun 15 '17 15:06 evenicoulddoit

evenicoulddoit: its the same thing as in my answer the only difference is that you added popover-popup-close-delay

odedkeren1 avatar Jun 15 '17 16:06 odedkeren1

@odedkeren1 The timeouts in my version allow the tooltip to not be immediately touching the parent, though the actual solution I've come up with for work also works for tooltip-append-to-body

evenicoulddoit avatar Jun 16 '17 07:06 evenicoulddoit

Easiest way to have a mouse-event using uib-popover Look at the below working example ! https://plnkr.co/edit/9oMYadXPNJcRPrig71iF?p=preview

VenkatRamReddyK avatar Nov 20 '17 22:11 VenkatRamReddyK

@VenkatRamReddyK its the same as my answer. and by the way you have popover-trigger="outsideClick" no meaning to have it, you can use "none"

odedkeren1 avatar Nov 21 '17 17:11 odedkeren1

@evenicoulddoit it doesn't work for popover-append-to-body="true". how this can be resolved?

bmrinal avatar Nov 28 '17 03:11 bmrinal

@bmrinal https://plnkr.co/edit/kciyLQ6LZQRNdkj1xQNB?p=preview

evenicoulddoit avatar Nov 28 '17 08:11 evenicoulddoit

@evenicoulddoit it still closes the popover when cursor is inside it

bmrinal avatar Dec 04 '17 11:12 bmrinal

@bmrinal @evenicoulddoit I am in need of it working with popover-append-to-body="true" as well!

changus avatar Dec 06 '17 18:12 changus