Skip to content

Commit 2aa54a5

Browse files
authored
fix: Dashboard scrolls when selecting row in data browser (#2559)
1 parent 6e0881c commit 2aa54a5

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/components/BrowserCell/BrowserCell.react.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -223,21 +223,23 @@ export default class BrowserCell extends Component {
223223
?.catch(err => console.log(err));
224224
}
225225
if (this.props.current) {
226-
const node = this.cellRef.current;
227-
const { setRelation } = this.props;
228-
const { left, right, bottom, top } = node.getBoundingClientRect();
229-
230-
// Takes into consideration Sidebar width when over 980px wide.
231-
// If setRelation is undefined, DataBrowser is used as ObjectPicker, so it does not have a sidebar.
232-
const leftBoundary = window.innerWidth > 980 && setRelation ? 300 : 0;
233-
234-
// BrowserToolbar + DataBrowserHeader height
235-
const topBoundary = 126;
236-
237-
if (left < leftBoundary || right > window.innerWidth) {
238-
node.scrollIntoView({ block: 'nearest', inline: 'start' });
239-
} else if (top < topBoundary || bottom > window.innerHeight) {
240-
node.scrollIntoView({ block: 'nearest', inline: 'nearest' });
226+
if (prevProps.selectedCells === this.props.selectedCells) {
227+
const node = this.cellRef.current;
228+
const { setRelation } = this.props;
229+
const { left, right, bottom, top } = node.getBoundingClientRect();
230+
231+
// Takes into consideration Sidebar width when over 980px wide.
232+
// If setRelation is undefined, DataBrowser is used as ObjectPicker, so it does not have a sidebar.
233+
const leftBoundary = window.innerWidth > 980 && setRelation ? 300 : 0;
234+
235+
// BrowserToolbar + DataBrowserHeader height
236+
const topBoundary = 126;
237+
238+
if (left < leftBoundary || right > window.innerWidth) {
239+
node.scrollIntoView({ block: 'nearest', inline: 'start' });
240+
} else if (top < topBoundary || bottom > window.innerHeight) {
241+
node.scrollIntoView({ block: 'nearest', inline: 'nearest' });
242+
}
241243
}
242244

243245
if (!this.props.hidden) {

0 commit comments

Comments
 (0)