Skip to content

Commit

Permalink
fix: Dashboard scrolls when selecting row in data browser (#2559)
Browse files Browse the repository at this point in the history
  • Loading branch information
devbymak authored May 15, 2024
1 parent 6e0881c commit 2aa54a5
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/components/BrowserCell/BrowserCell.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 2aa54a5

Please sign in to comment.