Unfortunately the tooltip component does only work for elements that are present at first rendering.
If elements are surrounded by an if-condition which becomes true at a later point in time, the tooltip is not displayed.
Our usecase: We have tables where some data is computed after displaying the rest of the table. The computing and displaying works and the title is there (and shown in the default windows tooltip) but the Telerik tooltip is not displayed.
This is an old post but wWe came across the same problem recently but the workaround only partially solves it.
If the tooltip is visible on the button that triggers the change, then the value never gets reset but instead reverts to the base title tooltip. Consider the following where the TelerikTooltip targets a .tooltip-target which is setup in the TelerikButton. When the button is pressed the tooltip should update but fails to.
Our example is based around an Undo/Redo action where the tooltip shows the action of the button which is dynamically set and updated based on what the available actions are. We gained a solution outside of relying on the tooltip with styling divs to mimic the tooltip.
That however highlights another problem that the tooltip still tries to show if its bound dynamically to a null or empty string.
}
Hello,
I have updated the title of this idea because it may be done in another way, not necessarily through an explicit method.
Regards,
Marin Bratanov
Progress Telerik
Hello Marin,
thanks a lot for the workaround!
Regards,
René
Hello Ben,
The search bar when you submit a ticket and on our site generally already searches through the feedback portals. Of course, you can also search the feedback portal explicitly for issues or feature requests that already exist.
As for a KB section - we have one inside the docs: https://docs.telerik.com/blazor-ui/knowledge-base. I tend to not add those workarounds there because it will make for a bunch of articles that will go stale pretty quickly. Each time we fix or implement something, there will be a KB article left that will confuse people in the future. I've seen something like this happen and I am trying to future-proof the information. The downside is that some solutions are only available here in this portal. At this point I feel like I'd rather take on some workload than risk confusing thousands of people in the future with outdated information.
Regards,
Marin Bratanov
Progress Telerik
Hello,
This behavior is expected - the tooltip component has initialized with a certain DOM and it cannot monitor when the Blazor framework will make changes to it. The solution is to make the tooltip refresh. At the moment, this can be done by hiding and re-showing it (example below). I have also renamed this page to showcase what can be done.
Another approach to solve this would be to add a TelerikTooltip to such new content. We do something similar in the following example that also showcases load-on-demand in a grid: https://github.com/telerik/blazor-ui/tree/master/tooltip/in-grid
@if (RepaintTooltipFlag)
{
<TelerikTooltip TargetSelector="p a[title], span[title]">
</TelerikTooltip>
}
<p>
<a title="what is 'lorem ipsum'?" href="https://lipsum.com/">lorem</a>
ipsum dolor
<a title="is this a real word?" href="https://en.wikipedia.org/wiki/SIT">sit</a>
amet.
</p>
<TelerikButton OnClick="@AddMoreContent">show more content</TelerikButton>
@if (AllContentVisible)
{
<p>more content <span title="I will not have a Telerik Tooltip unless you take measures" style="font-weight: bold;">here</span></p>
}
@code{
bool AllContentVisible { get; set; }
//part of workaround
bool RepaintTooltipFlag { get; set; } = true;
async Task AddMoreContent()
{
AllContentVisible = true;
//workaround
RepaintTooltipFlag = false;
await Task.Delay(30);
RepaintTooltipFlag = true;
//at best, this can be replaced with a reference to the tooltip and a .Refresh() method on it
//that you can call at points when you need it to re-evaluate targets
}
}
EDIT: Here's an example of adding a tooltip to the new content as well
<TelerikTooltip TargetSelector="p a[title]">
</TelerikTooltip>
<p>
<a title="what is 'lorem ipsum'?" href="https://lipsum.com/">lorem</a>
ipsum dolor
<a title="is this a real word?" href="https://en.wikipedia.org/wiki/SIT">sit</a>
amet.
</p>
<TelerikButton OnClick="@AddMoreContent">show more content</TelerikButton>
@if (AllContentVisible)
{
<p id="newContent">more content <span title="I will not have a Telerik Tooltip unless you take measures" style="font-weight: bold;">here</span></p>
<TelerikTooltip TargetSelector="#newContent span[title]"></TelerikTooltip>
}
@code{
bool AllContentVisible { get; set; }
async Task AddMoreContent()
{
AllContentVisible = true;
}
}
Regards,
Marin Bratanov
Progress Telerik