From 5907be6db98658e62fab0194be59a0cf3243be2c Mon Sep 17 00:00:00 2001 From: Andrii Vorobiov Date: Thu, 23 Nov 2023 17:51:15 +0200 Subject: [PATCH] ui: keep timewindow with fixed range after Now button click This change fixes behavior of Now button in TimeScale component. Before, when user selected some custom time range then clicked Now button - it would not update charts because there was inconsistency. Custom time range cannot be with "moving" attribute, it cannot be updated every time to reflect most recent data as custom range has fixed end time. This change checks if current preset is custom and doesn't set "moving" attribute in this case. Epic: None Release note (ui change): proper handling of "Now" button on Time range selector when custom time period was selected before. --- .../cluster-ui/src/timeScaleDropdown/timeScaleDropdown.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.tsx b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.tsx index 61016ca9de61..67adc2ba9129 100644 --- a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.tsx @@ -183,7 +183,12 @@ export const TimeScaleDropdown: React.FC = ({ case ArrowDirection.CENTER: // CENTER is used to set the time window to the current time. endTime = now; - isMoving = true; + // Only predefined time ranges are considered to be moving window (ie Past Hour, Past 3 days, etc). + // Custom time window has specific start/end time and constant duration, and in this case we + // move time window with the same duration with end time = now() and keep it fixed as before. + if (key !== "Custom") { + isMoving = true; + } break; default: getLogger().error("Unknown direction: ", direction);