@@ -259,18 +259,19 @@ export const useZoomRequeryXDomainSettings = (args: ZoomRequeryArgs) => {
259259 }
260260 } , [ domain ] ) // eslint-disable-line react-hooks/exhaustive-deps
261261
262- // sync preZoomDomain and domain
263- // - when query results change to refit the graph
264- // - when it is the time axis, then only if the timeRange has changed
262+ // sync preZoomDomain and domain only when not zoomed in
263+ // - if they are different, or
264+ // - if it is the time axis and the time range has changed
265265 useEffect ( ( ) => {
266266 if (
267- ( ! timeRange || isNotEqual ( timeRange , selectedTimeRange ) ) &&
268- isNotEqual ( preZoomDomain , domain )
267+ ! preZoomResult &&
268+ ( isNotEqual ( preZoomDomain , domain ) ||
269+ ( timeRange && isNotEqual ( timeRange , selectedTimeRange ) ) )
269270 ) {
270271 setSelectedTimeRange ( timeRange )
271272 setDomain ( preZoomDomain )
272273 }
273- } , [ preZoomDomain ] ) // eslint-disable-line react-hooks/exhaustive-deps
274+ } , [ domain , preZoomDomain , preZoomResult , selectedTimeRange , timeRange ] )
274275
275276 useEffect ( ( ) => {
276277 if ( timeRange ) {
@@ -419,18 +420,19 @@ export const useZoomRequeryYDomainSettings = (args: ZoomRequeryArgs) => {
419420 }
420421 } , [ domain ] ) // eslint-disable-line react-hooks/exhaustive-deps
421422
422- // sync preZoomDomain and domain
423- // - when query results change to refit the graph
424- // - when it is the time axis, then only if the timeRange has changed
423+ // sync preZoomDomain and domain only when not zoomed in
424+ // - if they are different, or
425+ // - if it is the time axis and the time range has changed
425426 useEffect ( ( ) => {
426427 if (
427- ( ! timeRange || isNotEqual ( timeRange , selectedTimeRange ) ) &&
428- isNotEqual ( preZoomDomain , domain )
428+ ! preZoomResult &&
429+ ( isNotEqual ( preZoomDomain , domain ) ||
430+ ( timeRange && isNotEqual ( timeRange , selectedTimeRange ) ) )
429431 ) {
430432 setSelectedTimeRange ( timeRange )
431433 setDomain ( preZoomDomain )
432434 }
433- } , [ preZoomDomain ] ) // eslint-disable-line react-hooks/exhaustive-deps
435+ } , [ domain , preZoomDomain , preZoomResult , selectedTimeRange , timeRange ] )
434436
435437 useEffect ( ( ) => {
436438 if ( timeRange ) {
0 commit comments