From 65b8002aebb7c2ae95e5eb1cd436a6b4e086693c Mon Sep 17 00:00:00 2001
From: Yury Molodov <yurymolodov@gmail.com>
Date: Tue, 6 Feb 2024 21:32:03 +0100
Subject: [PATCH] vmui: fix graph dragging (#5769)

Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
---
 app/vmui/packages/vmui/src/hooks/uplot/useReadyChart.ts | 2 +-
 docs/CHANGELOG.md                                       | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/vmui/packages/vmui/src/hooks/uplot/useReadyChart.ts b/app/vmui/packages/vmui/src/hooks/uplot/useReadyChart.ts
index 4388183e9d..198475c02d 100644
--- a/app/vmui/packages/vmui/src/hooks/uplot/useReadyChart.ts
+++ b/app/vmui/packages/vmui/src/hooks/uplot/useReadyChart.ts
@@ -20,7 +20,7 @@ const useReadyChart = (setPlotScale: SetMinMax) => {
   const onReadyChart = (u: uPlot): void => {
     const handleInteractionStart = (e: MouseEvent | TouchEvent) => {
       const dragByMouse = e instanceof MouseEvent && isLiftClickWithMeta(e);
-      const dragByTouch = e instanceof TouchEvent && e.touches.length > 1;
+      const dragByTouch = window.TouchEvent && e instanceof TouchEvent && e.touches.length > 1;
       if (dragByMouse || dragByTouch) {
         dragChart({ u, e });
       }
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 7165de2562..d8d219f91d 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -34,6 +34,7 @@ The sandbox cluster installation is running under the constant load generated by
 * FEATURE: [dashboards/all](https://grafana.com/orgs/victoriametrics): add new panel `CPU spent on GC`. It should help identifying cases when too much CPU is spent on garbage collection, and advice users on how this can be addressed.
 
 * BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): properly propagate [label filters](https://docs.victoriametrics.com/keyconcepts/#filtering) from multiple arguments passed to [aggregate functions](https://docs.victoriametrics.com/metricsql/#aggregate-functions). For example, `sum({job="foo"}, {job="bar"}) by (job) + a` was improperly optimized to `sum({job="foo"}, {job="bar"}) by (job) + a{job="foo"}` before being executed. This could lead to unexpected results. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5604).
+* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): fix the graph dragging for Firefox and Safari. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5764).
 
 ## [v1.97.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.97.1)