fix: handle the super set query reset state when changing widgets (#5539)

This commit is contained in:
Vikrant Gupta 2024-07-23 20:21:25 +05:30 committed by GitHub
parent d50530f58c
commit d60daef171
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View File

@ -79,6 +79,7 @@ function NewWidget({ selectedGraph }: NewWidgetProps): JSX.Element {
stagedQuery,
redirectWithQueryBuilderData,
supersetQuery,
setSupersetQuery,
} = useQueryBuilder();
const isQueryModified = useMemo(
@ -548,6 +549,17 @@ function NewWidget({ selectedGraph }: NewWidgetProps): JSX.Element {
isNewTraceLogsAvailable,
]);
useEffect(() => {
/**
* we need this extra handling for superset query because we cannot keep this in sync with current query
* always.we do not sync superset query in the initQueryBuilderData because that function is called on all stage and run
* actions. we do not want that as we loose out on superset functionalities if we do the same. hence initialising the superset query
* on mount here with the currentQuery in the begining itself
*/
setSupersetQuery(currentQuery);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect(() => {
registerShortcut(DashboardShortcuts.SaveChanges, onSaveDashboard);
registerShortcut(DashboardShortcuts.DiscardChanges, onClickDiscardHandler);

View File

@ -829,7 +829,7 @@ export function QueryBuilderProvider({
unit,
}));
},
[setCurrentQuery],
[setCurrentQuery, setSupersetQuery],
);
const query: Query = useMemo(