Explore: Reset Graph overrides if underlying series changes (#49680)

This commit is contained in:
Giordano Ricci 2022-05-26 06:02:21 -07:00 committed by GitHub
parent e25a49ff49
commit a59066a21d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,12 +75,8 @@ export function ExploreGraph({
const previousData = usePrevious(data);
const structureChangesRef = useRef(0);
if (data && previousData && !compareArrayValues(previousData, data, compareDataFrameStructures)) {
structureChangesRef.current++;
}
const structureRev = baseStructureRev + structureChangesRef.current;
const prevStructureRev = usePrevious(structureRev);
const [fieldConfig, setFieldConfig] = useState<FieldConfigSource>({
defaults: {
@ -96,6 +92,14 @@ export function ExploreGraph({
overrides: [],
});
if (data && previousData && !compareArrayValues(previousData, data, compareDataFrameStructures)) {
structureChangesRef.current++;
if (prevStructureRev === structureRev) {
setFieldConfig({ ...fieldConfig, overrides: [] });
}
}
const style = useStyles2(getStyles);
const timeRange = {
from: dateTime(absoluteRange.from),