Skip to content

Commit

Permalink
fix(UI): element list scrollbar back to the top after page change (Co…
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwiniHerle authored Jun 7, 2024
1 parent 7f23ac3 commit 8c235ed
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/packs/src/apps/mydb/elements/list/ElementsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import CellLineContainer from 'src/apps/mydb/elements/list/cellLine/CellLineCont
export default class ElementsTable extends React.Component {
constructor(props) {
super(props);
this.elementRef = React.createRef();

this.state = {
elements: [],
Expand Down Expand Up @@ -76,9 +77,15 @@ export default class ElementsTable extends React.Component {
}, () => {
const { page } = this.state;
UIActions.setPagination({ type, page });
this.handleScrollToElement(this.elementRef);
});
}
}
handleScrollToElement = () => {
if (this.elementRef.current) {
this.elementRef.current.scrollTo({ top: 0, left: 0, behavior: "smooth", });
}
};

onChangeUI(state) {
const { type } = this.props;
Expand Down Expand Up @@ -682,7 +689,7 @@ export default class ElementsTable extends React.Component {
}

return (
<div className="list-elements">
<div ref={this.elementRef} className="list-elements">
{elementsTableEntries}
</div>
);
Expand Down

0 comments on commit 8c235ed

Please sign in to comment.