Skip to content

Commit 2b78087

Browse files
authored
fix: Info panel scroll-to-top setting not persistent across dashboard sessions (#2938)
1 parent 628e1c0 commit 2b78087

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import AggregationPanel from '../../../components/AggregationPanel/AggregationPa
2121

2222
const BROWSER_SHOW_ROW_NUMBER = 'browserShowRowNumber';
2323
const AGGREGATION_PANEL_VISIBLE = 'aggregationPanelVisible';
24+
const BROWSER_SCROLL_TO_TOP = 'browserScrollToTop';
2425

2526
function formatValueForCopy(value, type) {
2627
if (value === undefined) {
@@ -83,6 +84,8 @@ export default class DataBrowser extends React.Component {
8384
window.localStorage?.getItem(BROWSER_SHOW_ROW_NUMBER) === 'true';
8485
const storedPanelVisible =
8586
window.localStorage?.getItem(AGGREGATION_PANEL_VISIBLE) === 'true';
87+
const storedScrollToTop =
88+
window.localStorage?.getItem(BROWSER_SCROLL_TO_TOP) !== 'false';
8689
const hasAggregation =
8790
props.classwiseCloudFunctions?.[
8891
`${props.app.applicationId}${props.appName}`
@@ -107,7 +110,7 @@ export default class DataBrowser extends React.Component {
107110
showAggregatedData: true,
108111
frozenColumnIndex: -1,
109112
showRowNumber: storedRowNumber,
110-
scrollToTop: true,
113+
scrollToTop: storedScrollToTop,
111114
prefetchCache: {},
112115
selectionHistory: [],
113116
};
@@ -669,7 +672,11 @@ export default class DataBrowser extends React.Component {
669672
}
670673

671674
toggleScrollToTop() {
672-
this.setState(prevState => ({ scrollToTop: !prevState.scrollToTop }));
675+
this.setState(prevState => {
676+
const newScrollToTop = !prevState.scrollToTop;
677+
window.localStorage?.setItem(BROWSER_SCROLL_TO_TOP, newScrollToTop);
678+
return { scrollToTop: newScrollToTop };
679+
});
673680
}
674681

675682
getPrefetchSettings() {

0 commit comments

Comments
 (0)