mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Fix new-old-new query history bug (#90214)
* Remove cancelActiveListeners() and delay() * Wait for handle history to resolve * Do not sync from URL when state changes --------- Co-authored-by: harisrozajac <haris.rozajac12@gmail.com>
This commit is contained in:
parent
62494248e3
commit
b09798c3fa
@ -20,6 +20,7 @@ export function useStateSync(params: ExploreQueryParams) {
|
||||
const { location } = useGrafana();
|
||||
const dispatch = useDispatch();
|
||||
const panesState = useSelector(selectPanes);
|
||||
const panesStateRef = useRef(panesState);
|
||||
const orgId = useSelector((state) => state.user.orgId);
|
||||
const prevParams = useRef(params);
|
||||
const initState = useRef<'notstarted' | 'pending' | 'done'>('notstarted');
|
||||
@ -53,6 +54,10 @@ export function useStateSync(params: ExploreQueryParams) {
|
||||
return () => unsubscribe();
|
||||
}, [dispatch, location]);
|
||||
|
||||
useEffect(() => {
|
||||
panesStateRef.current = panesState;
|
||||
}, [panesState]);
|
||||
|
||||
useEffect(() => {
|
||||
const isURLOutOfSync = prevParams.current?.panes !== params.panes;
|
||||
|
||||
@ -74,7 +79,7 @@ export function useStateSync(params: ExploreQueryParams) {
|
||||
prevParams.current = params;
|
||||
|
||||
if (isURLOutOfSync && initState.current === 'done') {
|
||||
syncFromURL(urlState, panesState, dispatch);
|
||||
syncFromURL(urlState, panesStateRef.current, dispatch);
|
||||
}
|
||||
}, [dispatch, panesState, orgId, location, params, warning]);
|
||||
}, [dispatch, orgId, location, params, warning]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user