Skip to content

Commit

Permalink
Tooltip position updated when forced to change
Browse files Browse the repository at this point in the history
  • Loading branch information
enchev committed Nov 21, 2024
1 parent a69909f commit a0f1545
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
19 changes: 17 additions & 2 deletions Radzen.Blazor/RadzenTooltip.razor
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@

protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);

IsJSRuntimeAvailable = true;

var tooltip = tooltips.LastOrDefault();
Expand Down Expand Up @@ -85,9 +87,22 @@
/// Closes this instance.
/// </summary>
[JSInvokable("RadzenTooltip.CloseTooltip")]
public void CloseTooltip()
public async Task CloseTooltip(string position = null)
{
Service.Close();
if (position == null)
{
Service.Close();
}
else
{
var tooltip = tooltips.LastOrDefault();

if (tooltip != null)
{
tooltip.Options.Position = (TooltipPosition)Enum.Parse(typeof(TooltipPosition), position, true);
await InvokeAsync(() => { StateHasChanged(); });
}
}
}

public async Task Close()
Expand Down
7 changes: 7 additions & 0 deletions Radzen.Blazor/wwwroot/Radzen.Blazor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,10 @@ window.Radzen = {
if (tooltipContent.classList.contains(tooltipContentClassName)) {
tooltipContent.classList.remove(tooltipContentClassName);
tooltipContent.classList.add('rz-top-tooltip-content');
position = 'top';
if (instance && callback) {
instance.invokeMethodAsync(callback, position);
}
}
}
}
Expand All @@ -1170,6 +1174,9 @@ window.Radzen = {
tooltipContent.classList.remove(tooltipContentClassName);
tooltipContent.classList.add('rz-left-tooltip-content');
position = 'left';
if (instance && callback) {
instance.invokeMethodAsync(callback, position);
}
}
}
}
Expand Down

0 comments on commit a0f1545

Please sign in to comment.