Skip to content

Commit bf46938

Browse files
authored
fix: Sync-scrolling multiple panels stops at bottom of shortest panel when scrolling down (#3024)
1 parent 7f27f34 commit bf46938

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

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

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,18 @@ export default class DataBrowser extends React.Component {
169169
this.panelColumnRefs = [];
170170
this.activePanelIndex = -1;
171171
this.isWheelScrolling = false;
172-
this.multiPanelWrapperRef = React.createRef();
172+
this.multiPanelWrapperElement = null;
173+
this.setMultiPanelWrapperRef = this.setMultiPanelWrapperRef.bind(this);
174+
}
175+
176+
setMultiPanelWrapperRef(element) {
177+
if (this.multiPanelWrapperElement) {
178+
this.multiPanelWrapperElement.removeEventListener('wheel', this.handleWrapperWheel);
179+
}
180+
this.multiPanelWrapperElement = element;
181+
if (element && this.state.panelCount > 1 && this.state.syncPanelScroll) {
182+
element.addEventListener('wheel', this.handleWrapperWheel, { passive: false });
183+
}
173184
}
174185

175186
componentWillReceiveProps(props) {
@@ -231,18 +242,13 @@ export default class DataBrowser extends React.Component {
231242
componentDidMount() {
232243
document.body.addEventListener('keydown', this.handleKey);
233244
window.addEventListener('resize', this.updateMaxWidth);
234-
// Add wheel event listener for multi-panel scrolling
235-
if (this.multiPanelWrapperRef.current && this.state.panelCount > 1 && this.state.syncPanelScroll) {
236-
this.multiPanelWrapperRef.current.addEventListener('wheel', this.handleWrapperWheel, { passive: false });
237-
}
238245
}
239246

240247
componentWillUnmount() {
241248
document.body.removeEventListener('keydown', this.handleKey);
242249
window.removeEventListener('resize', this.updateMaxWidth);
243-
// Remove wheel event listener
244-
if (this.multiPanelWrapperRef.current) {
245-
this.multiPanelWrapperRef.current.removeEventListener('wheel', this.handleWrapperWheel);
250+
if (this.multiPanelWrapperElement) {
251+
this.multiPanelWrapperElement.removeEventListener('wheel', this.handleWrapperWheel);
246252
}
247253
}
248254

@@ -314,13 +320,13 @@ export default class DataBrowser extends React.Component {
314320
const prevNeedsListener = prevState.panelCount > 1 && prevState.syncPanelScroll;
315321
const nowNeedsListener = this.state.panelCount > 1 && this.state.syncPanelScroll;
316322

317-
if (prevNeedsListener !== nowNeedsListener && this.multiPanelWrapperRef.current) {
323+
if (prevNeedsListener !== nowNeedsListener && this.multiPanelWrapperElement) {
318324
if (nowNeedsListener) {
319325
// Add listener
320-
this.multiPanelWrapperRef.current.addEventListener('wheel', this.handleWrapperWheel, { passive: false });
326+
this.multiPanelWrapperElement.addEventListener('wheel', this.handleWrapperWheel, { passive: false });
321327
} else {
322328
// Remove listener
323-
this.multiPanelWrapperRef.current.removeEventListener('wheel', this.handleWrapperWheel);
329+
this.multiPanelWrapperElement.removeEventListener('wheel', this.handleWrapperWheel);
324330
}
325331
}
326332
}
@@ -1447,7 +1453,7 @@ export default class DataBrowser extends React.Component {
14471453
{this.state.panelCount > 1 ? (
14481454
<div
14491455
className={styles.multiPanelWrapper}
1450-
ref={this.multiPanelWrapperRef}
1456+
ref={this.setMultiPanelWrapperRef}
14511457
>
14521458
{(() => {
14531459
// Initialize refs array if needed

0 commit comments

Comments
 (0)