Skip to content

Commit f7101ce

Browse files
committed
fix: reset aggregation panel scroll when loading cached data
1 parent d4bce76 commit f7101ce

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/components/AggregationPanel/AggregationPanel.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import LoaderDots from 'components/LoaderDots/LoaderDots.react';
22
import Parse from 'parse';
3-
import React, { useCallback, useEffect, useMemo, useState } from 'react';
3+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
44
import styles from './AggregationPanel.scss';
55
import {
66
AudioElement,
@@ -31,6 +31,13 @@ const AggregationPanel = ({
3131
const [isExpanded, setIsExpanded] = useState(false);
3232
const [nestedData, setNestedData] = useState(null);
3333
const [isLoadingNested, setIsLoadingNested] = useState(false);
34+
const containerRef = useRef(null);
35+
36+
useEffect(() => {
37+
if (containerRef.current) {
38+
containerRef.current.scrollTop = 0;
39+
}
40+
}, [data, selectedObjectId]);
3441

3542
useEffect(() => {
3643
if (Object.keys(errorAggregatedData).length !== 0) {
@@ -191,7 +198,7 @@ const AggregationPanel = ({
191198
}
192199

193200
return (
194-
<div className={styles.aggregationPanel}>
201+
<div className={styles.aggregationPanel} ref={containerRef}>
195202
{isLoadingInfoPanel ? (
196203
<div className={styles.center}>
197204
<LoaderDots />

src/dashboard/Data/Browser/DataBrowser.react.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ export default class DataBrowser extends React.Component {
132132
this.setShowRowNumber = this.setShowRowNumber.bind(this);
133133
this.handleCellClick = this.handleCellClick.bind(this);
134134
this.saveOrderTimeout = null;
135-
this.aggregationPanelRef = React.createRef();
136135
}
137136

138137
componentWillReceiveProps(props) {
@@ -735,9 +734,6 @@ export default class DataBrowser extends React.Component {
735734
const { prefetchCache } = this.state;
736735
const { prefetchStale } = this.getPrefetchSettings();
737736
const cached = prefetchCache[objectId];
738-
if (this.aggregationPanelRef.current) {
739-
this.aggregationPanelRef.current.scrollTop = 0;
740-
}
741737
if (
742738
cached &&
743739
(!prefetchStale || (Date.now() - cached.timestamp) / 1000 < prefetchStale)
@@ -906,10 +902,7 @@ export default class DataBrowser extends React.Component {
906902
resizeHandles={['w']}
907903
className={styles.resizablePanel}
908904
>
909-
<div
910-
className={styles.aggregationPanelContainer}
911-
ref={this.aggregationPanelRef}
912-
>
905+
<div className={styles.aggregationPanelContainer}>
913906
<AggregationPanel
914907
data={this.props.AggregationPanelData}
915908
isLoadingCloudFunction={this.props.isLoadingCloudFunction}

0 commit comments

Comments
 (0)