diff --git a/Radzen.Blazor/RadzenTooltip.razor b/Radzen.Blazor/RadzenTooltip.razor index c40e59351a6..3f0a7078f5c 100644 --- a/Radzen.Blazor/RadzenTooltip.razor +++ b/Radzen.Blazor/RadzenTooltip.razor @@ -44,6 +44,8 @@ protected override async Task OnAfterRenderAsync(bool firstRender) { + await base.OnAfterRenderAsync(firstRender); + IsJSRuntimeAvailable = true; var tooltip = tooltips.LastOrDefault(); @@ -85,9 +87,22 @@ /// Closes this instance. /// [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() diff --git a/Radzen.Blazor/wwwroot/Radzen.Blazor.js b/Radzen.Blazor/wwwroot/Radzen.Blazor.js index 2b58178a928..376b70b2626 100644 --- a/Radzen.Blazor/wwwroot/Radzen.Blazor.js +++ b/Radzen.Blazor/wwwroot/Radzen.Blazor.js @@ -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); + } } } } @@ -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); + } } } }