From 022a1b862a74de5edb7a7d42ef154bfd3094c98f Mon Sep 17 00:00:00 2001 From: MohammadAli Karimi Date: Mon, 13 May 2024 17:16:09 +0400 Subject: [PATCH 1/2] fix: jump-up scroll on select row when cell selected --- .../BrowserCell/BrowserCell.react.js | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/components/BrowserCell/BrowserCell.react.js b/src/components/BrowserCell/BrowserCell.react.js index ec0880eadb..71425dc735 100644 --- a/src/components/BrowserCell/BrowserCell.react.js +++ b/src/components/BrowserCell/BrowserCell.react.js @@ -43,8 +43,8 @@ export default class BrowserCell extends Component { this.props.value !== undefined || !isNewRow ? '(hidden)' : this.props.isRequired - ? '(required)' - : '(undefined)'; + ? '(required)' + : '(undefined)'; classes.push(styles.empty); } else if (this.props.value === undefined) { if (this.props.type === 'ACL') { @@ -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) { @@ -400,8 +402,8 @@ export default class BrowserCell extends Component { copyableValue.length < 30 ? copyableValue : `${copyableValue.substr(0, 20)}...${copyableValue.substr( - copyableValue.length - 7 - )}`; + copyableValue.length - 7 + )}`; const text = `${this.props.field} ${definition.name}${ definition.comparable ? ' ' + value : '' }`; @@ -491,9 +493,9 @@ export default class BrowserCell extends Component { compareTo = value.__type ? value : { - __type: 'Date', - iso: value, - }; + __type: 'Date', + iso: value, + }; break; default: From f0cbca83bdf83db194161614267ac2c918f8e526 Mon Sep 17 00:00:00 2001 From: MohammadAli Karimi Date: Mon, 13 May 2024 17:20:51 +0400 Subject: [PATCH 2/2] fix: revert format code --- src/components/BrowserCell/BrowserCell.react.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/BrowserCell/BrowserCell.react.js b/src/components/BrowserCell/BrowserCell.react.js index 71425dc735..a033568c77 100644 --- a/src/components/BrowserCell/BrowserCell.react.js +++ b/src/components/BrowserCell/BrowserCell.react.js @@ -43,8 +43,8 @@ export default class BrowserCell extends Component { this.props.value !== undefined || !isNewRow ? '(hidden)' : this.props.isRequired - ? '(required)' - : '(undefined)'; + ? '(required)' + : '(undefined)'; classes.push(styles.empty); } else if (this.props.value === undefined) { if (this.props.type === 'ACL') { @@ -402,8 +402,8 @@ export default class BrowserCell extends Component { copyableValue.length < 30 ? copyableValue : `${copyableValue.substr(0, 20)}...${copyableValue.substr( - copyableValue.length - 7 - )}`; + copyableValue.length - 7 + )}`; const text = `${this.props.field} ${definition.name}${ definition.comparable ? ' ' + value : '' }`; @@ -493,9 +493,9 @@ export default class BrowserCell extends Component { compareTo = value.__type ? value : { - __type: 'Date', - iso: value, - }; + __type: 'Date', + iso: value, + }; break; default: