Forum Discussion
Custom visual: Tooltip closes after opening
Hi arthur_clifford,
I've developed many visuals and have never run into this problem with tooltips. Tooltip invocation in Power BI is pretty straightforward—you either populate the data manually (for a standard tooltip) or provide a valid selection ID based on the data Power BI initially sends to the data view for a report page tooltip. If the selection ID is not valid, it usually displays a standard tooltip, as it cannot resolve your selector against the data model. Tooltips are shown with .show() and hidden with .hide() events, wired up to event handlers as needed. Power BI should take care of the .hide() event via the visual host when the mouse is moved out of the visual, so normally, a subsequent .show() by your logic is called; this should work as expected.
I'm having trouble understanding how you are implementing your specific use case. Admittedly, I haven't tried populating tooltip info via an API call, but my understanding is that I might use the following high-level workflow, so that I'm using the tooltip service APIs as intended:
- Desired mouse event to invoke the tooltip is fired
- The API is called (assuming you're using fetch()...)
- In the promise callback (fetch.then()), build tooltip information and call .show() via the tooltip service
In the last step, I'd include any selection IDs I need for the given dataset row so that Power BI displays the correct tooltip for the desired row context.
If you're calling an API and trying to fabricate selection IDs, this is likely not going to be supported and sounds like something that Power BI may not be able to reconcile, unless you are somehow getting a valid data view that you can generate legitimate selection IDs against. However, I don't think it'll be easy to assist further without seeing some code - can you share this?
Many thanks,
Daniel
Daniel, I added what I thought was a response to your question but I think it posted as a second comment on my original post.
I'm using this code to create my selectionIds
If you can see my previous post you can see that I am doing a communication with an api on on response sending info back to the powerbi visual such that it is showing results in the popup. So at a high level what you outlined is roughly what is happening with the addition of visual to iframe intercommunication.
I've somewhat improved things by catching mouse mouse movement better,sooner, to try to hide the tooltip before the user can trigger a mouse over on the tooltip itself.
Do you know how I would bring this up with the PowerBI developers if I had to? I'd like to know if the mouse over or enter event for the tooltip is triggering a different close function than the one in the tooltip service and whether there is some state or style that it should clear that it isn't.