From a0f1545421ca2d6a00248840de6be33d506f288f Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Thu, 21 Nov 2024 14:47:39 +0200 Subject: [PATCH] Tooltip position updated when forced to change --- Radzen.Blazor/RadzenTooltip.razor | 19 +++++++++++++++++-- Radzen.Blazor/wwwroot/Radzen.Blazor.js | 7 +++++++ 2 files changed, 24 insertions(+), 2 deletions(-) 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); + } } } }