Skip to content

Commit 735ce26

Browse files
authored
Fix graphs not using the global timerange (#79)
* Set global timerange in the first render * Apply OpenAPI suggestion
1 parent 166e8a8 commit 735ce26

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

public/app/core/components/TimePicker/TimePickerWithHistory.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,17 @@ export const Picker: FC<PickerProps> = ({ rawValues, onSaveToStore, pickerProps
6565
})
6666
);
6767
}
68+
} else if (fnGlobalTimeRange && !isEqual(fnGlobalTimeRange, pickerProps.value)) {
69+
/* If fnGlobalTimeRange exists in the initial render, set the time as that */
70+
pickerProps.onChange(fnGlobalTimeRange);
6871
}
6972

7073
didMountRef.current = true;
71-
}, [dispatch, fnGlobalTimeRange?.raw, pickerProps.value]);
74+
}, [dispatch, fnGlobalTimeRange, pickerProps]);
7275

7376
return (
7477
<TimeRangePicker
7578
{...pickerProps}
76-
value={fnGlobalTimeRange || pickerProps.value}
7779
history={history}
7880
onChange={(value) => {
7981
onAppendToHistory(value, values, onSaveToStore);

0 commit comments

Comments
 (0)