Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

feat: clean up tooltip elements and add dependencies (#8815)

Yunus M2acdd101d839
diff --git a/frontend/src/components/Uplot/Uplot.tsx b/frontend/src/components/Uplot/Uplot.tsx
index cd9ece5212..8bb044552a 100644
--- a/frontend/src/components/Uplot/Uplot.tsx
+++ b/frontend/src/components/Uplot/Uplot.tsx
@@ -62,7 +62,7 @@ const Uplot = forwardRef<ToggleGraphProps | undefined, UplotProps>(
useEffect(() => {
onCreateRef.current = onCreate;
onDeleteRef.current = onDelete;
- });
+ }, [onCreate, onDelete]);
const destroy = useCallback((chart: uPlot | null) => {
if (chart) {
@@ -71,12 +71,25 @@ const Uplot = forwardRef<ToggleGraphProps | undefined, UplotProps>(
chartRef.current = null;
}
- // remove chart tooltip on cleanup
+ // Clean up tooltip overlay that might be detached
const overlay = document.getElementById('overlay');
-
if (overlay) {
+ // Remove all child elements from overlay
+ while (overlay.firstChild) {
+ overlay.removeChild(overlay.firstChild);
+ }
overlay.style.display = 'none';
}
+
+ // Clean up any remaining tooltips that might be detached
+ const tooltips = document.querySelectorAll(
+ '.uplot-tooltip, .tooltip-container',
+ );
+ tooltips.forEach((tooltip) => {
+ if (tooltip && tooltip.parentNode) {
+ tooltip.parentNode.removeChild(tooltip);
+ }
+ });
}, []);
const create = useCallback(() => {
diff --git a/frontend/src/hooks/useInterval.ts b/frontend/src/hooks/useInterval.ts
index 2b332b9041..4d55e33d72 100644
--- a/frontend/src/hooks/useInterval.ts
+++ b/frontend/src/hooks/useInterval.ts
@@ -9,7 +9,7 @@ function useInterval(
useEffect(() => {
savedCallback.current = callback;
- });
+ }, [callback]);
useEffect(() => {
function tick(): void {
diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx
index 25cfbfb5ab..7cb99ad076 100644
--- a/frontend/src/index.tsx
+++ b/frontend/src/index.tsx
@@ -16,6 +16,8 @@ const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
+ staleTime: 2 * 60 * 1000, // 2 minutes - data becomes stale after 2 minutes
+ cacheTime: 5 * 60 * 1000, // 5 minutes - cache entries are garbage collected after 5 minutes
retry(failureCount, error): boolean {
if (
// in case of manually throwing errors please make sure to send error.response.status