[v9.4.x] CloudMonitor: Correctly re-render VisualMetricQueryEditor on TimeRange updates (#66786)

CloudMonitor: Correctly re-render `VisualMetricQueryEditor` on `TimeRange` updates (#66756)

Compare string value rather than object

(cherry picked from commit adf12d0e90)

Co-authored-by: Andreas Christou <andreas.christou@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2023-04-18 16:34:55 +00:00
committed by GitHub
co-authored by Andreas Christou
parent f650293066
commit 50d9084d35
@@ -48,7 +48,11 @@ export function Editor({
const [timeRange, setTimeRange] = useState<TimeRange>({ ...datasource.timeSrv.timeRange() });
const useTime = (time: TimeRange) => {
if (timeRange !== null && (timeRange.raw.from !== time.raw.from || timeRange.raw.to !== time.raw.to)) {
if (
timeRange !== null &&
(timeRange.raw.from.toString() !== time.raw.from.toString() ||
timeRange.raw.to.toString() !== time.raw.to.toString())
) {
setTimeRange({ ...time });
}
};