stevenbenner / jquery-powertip

:speech_balloon: A jQuery plugin that creates hover tooltips.
https://stevenbenner.github.io/jquery-powertip/
MIT License
820 stars 137 forks source link

Prevent tooltip opening if input trigger element has focus #159

Closed evbrew closed 2 years ago

evbrew commented 7 years ago

Hello, more of a how-to than an issue.

I'm using PowerTip on an input element to display a Tip containing an icon that executes a function (it copies the value of the input to all other inputs in the same column).

image

I have AJAX validation that occurs on the inputs onBlur event, so i don't want users to see the Tip while the field has focus (so they have to mouse out, which applies the onBlur validation, then they can use the Tip function).

I'm using the following instantiation options for PowerTip:

elRef.powerTip({ placement: 'e', mouseOnToPopup: true, smartPlacement: true, openEvents: [ 'mouseenter' ], closeEvents: [ 'mouseleave', 'focus' ], closeDelay: 750 });

It almost works since I've specified 'focus' as a closeEvent, but if the user gives focus to the input, then mouse outs of the field, if they mouse back over the input the Tip is shown as its triggered by the 'mouseenter' openEvent (since it doesn't correlate the closeEvents to current state - understandable) even though the input still has focus.

Any thoughts, tips or solutions appreciated.

stevenbenner commented 7 years ago

This is kind of an unusual case. You don't want tooltips to show unless a specific case is met (element does not have focus).

I think your best bet will be Custom PowerTip Integration. Because that will give you the chance to add logic to prevent to tooltip opening.

edit: Actually, this is more difficult than I thought because you want to be able to mouse onto the tooltip. Right now the code that supports that is disabled when the manual option is set (maybe that is not necessary?). Unfortunately, that means that you would have to implement that logic yourself.

I tried putting together an example supporting mouseOnToPopup behavior, but it's all kinds of buggy unless I reimplement a significant portion of what's built into PowerTip.

Perhaps the mouseOnToPopup code should not be disabled in manual mode. I'll look into why that is done.

For now, I hate to say it but I don't think PowerTip will do what you want. At least, not without a bunch of custom code.

evbrew commented 7 years ago

No problem, PowerTip is a great tool and this use case was certainly a bit outside of what its intended to do (more of an ad-hoc menu or action context extension in this case).

Thanks for taking a look into my question, much appreciated.

stevenbenner commented 2 years ago

Implementing support for this is looking too messy to me. I think we'll just have to accept this as a limitation of PowerTip.

If anyone finds this issue and has a clever solution or just wants to argue in favor of it then please leave your thoughts below.

Closing issue.