Skip to content

Commit 3f85f89

Browse files
authored
fix: Sync-scrolling multiple panels jumps to bottom of shortest panel when scrolling up (#3023)
1 parent dd9ea49 commit 3f85f89

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

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

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ export default class DataBrowser extends React.Component {
167167
this.saveOrderTimeout = null;
168168
this.aggregationPanelRef = React.createRef();
169169
this.panelColumnRefs = [];
170+
this.activePanelIndex = -1;
171+
this.isWheelScrolling = false;
170172
this.multiPanelWrapperRef = React.createRef();
171173
}
172174

@@ -912,6 +914,18 @@ export default class DataBrowser extends React.Component {
912914
return;
913915
}
914916

917+
if (this.isWheelScrolling) {
918+
return;
919+
}
920+
921+
if (
922+
this.activePanelIndex !== -1 &&
923+
this.activePanelIndex !== undefined &&
924+
this.activePanelIndex !== index
925+
) {
926+
return;
927+
}
928+
915929
// Sync scroll position to all other panel columns
916930
const scrollTop = event.target.scrollTop;
917931
this.panelColumnRefs.forEach((ref, i) => {
@@ -926,14 +940,33 @@ export default class DataBrowser extends React.Component {
926940
return;
927941
}
928942

943+
// Set wheel scrolling flag
944+
this.isWheelScrolling = true;
945+
if (this.wheelTimeout) {
946+
clearTimeout(this.wheelTimeout);
947+
}
948+
this.wheelTimeout = setTimeout(() => {
949+
this.isWheelScrolling = false;
950+
}, 100);
951+
929952
// Prevent default scrolling
930953
event.preventDefault();
931954

932-
// Apply scroll to all columns
955+
// Find the maximum scrollTop among all panels to use as the base
956+
let maxScrollTop = 0;
957+
this.panelColumnRefs.forEach((ref) => {
958+
if (ref && ref.current && ref.current.scrollTop > maxScrollTop) {
959+
maxScrollTop = ref.current.scrollTop;
960+
}
961+
});
962+
963+
// Apply delta to the max scrollTop and set it to all panels
933964
const delta = event.deltaY;
965+
const newScrollTop = maxScrollTop + delta;
966+
934967
this.panelColumnRefs.forEach((ref) => {
935968
if (ref && ref.current) {
936-
ref.current.scrollTop += delta;
969+
ref.current.scrollTop = newScrollTop;
937970
}
938971
});
939972
}
@@ -1430,6 +1463,9 @@ export default class DataBrowser extends React.Component {
14301463
<div
14311464
className={styles.panelColumn}
14321465
ref={this.panelColumnRefs[index]}
1466+
onMouseEnter={() => (this.activePanelIndex = index)}
1467+
onTouchStart={() => (this.activePanelIndex = index)}
1468+
onFocus={() => (this.activePanelIndex = index)}
14331469
onScroll={(e) => this.handlePanelScroll(e, index)}
14341470
>
14351471
{this.state.showPanelCheckbox && (

0 commit comments

Comments
 (0)