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

This commit is contained in:
Yunus M 2025-09-16 11:08:51 +05:30 committed by GitHub
parent 39c2738ef9
commit 2acdd101d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 4 deletions

View File

@ -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(() => {

View File

@ -9,7 +9,7 @@ function useInterval(
useEffect(() => {
savedCallback.current = callback;
});
}, [callback]);
useEffect(() => {
function tick(): void {

View File

@ -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