From 2aa54a5bb1f356a7d4ed5abf3ea42c2e406d5b5a Mon Sep 17 00:00:00 2001 From: MohammadAli Karimi <65307721+devbymak@users.noreply.github.com> Date: Wed, 15 May 2024 22:24:33 +0400 Subject: [PATCH] fix: Dashboard scrolls when selecting row in data browser (#2559) --- .../BrowserCell/BrowserCell.react.js | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/components/BrowserCell/BrowserCell.react.js b/src/components/BrowserCell/BrowserCell.react.js index ec0880eadb..a033568c77 100644 --- a/src/components/BrowserCell/BrowserCell.react.js +++ b/src/components/BrowserCell/BrowserCell.react.js @@ -223,21 +223,23 @@ export default class BrowserCell extends Component { ?.catch(err => console.log(err)); } if (this.props.current) { - const node = this.cellRef.current; - const { setRelation } = this.props; - const { left, right, bottom, top } = node.getBoundingClientRect(); - - // Takes into consideration Sidebar width when over 980px wide. - // If setRelation is undefined, DataBrowser is used as ObjectPicker, so it does not have a sidebar. - const leftBoundary = window.innerWidth > 980 && setRelation ? 300 : 0; - - // BrowserToolbar + DataBrowserHeader height - const topBoundary = 126; - - if (left < leftBoundary || right > window.innerWidth) { - node.scrollIntoView({ block: 'nearest', inline: 'start' }); - } else if (top < topBoundary || bottom > window.innerHeight) { - node.scrollIntoView({ block: 'nearest', inline: 'nearest' }); + if (prevProps.selectedCells === this.props.selectedCells) { + const node = this.cellRef.current; + const { setRelation } = this.props; + const { left, right, bottom, top } = node.getBoundingClientRect(); + + // Takes into consideration Sidebar width when over 980px wide. + // If setRelation is undefined, DataBrowser is used as ObjectPicker, so it does not have a sidebar. + const leftBoundary = window.innerWidth > 980 && setRelation ? 300 : 0; + + // BrowserToolbar + DataBrowserHeader height + const topBoundary = 126; + + if (left < leftBoundary || right > window.innerWidth) { + node.scrollIntoView({ block: 'nearest', inline: 'start' }); + } else if (top < topBoundary || bottom > window.innerHeight) { + node.scrollIntoView({ block: 'nearest', inline: 'nearest' }); + } } if (!this.props.hidden) {