Skip to content

Commit

Permalink
Revert "remove(LibraryItem):forced scroll at componentDidMount (#188)"
Browse files Browse the repository at this point in the history
This reverts commit f3e0615.
  • Loading branch information
reddyashish authored May 23, 2024
1 parent 988543a commit 230f8bd
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/components/LibraryItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,26 @@ export class LibraryItem extends React.Component<LibraryItemProps, LibraryItemSt
}
}

//Afer rendering each Library item, scroll to the expanded item
componentDidMount() {
if (this.props.data.expanded && this.props.data.itemType !== "coregroup") {
//scroll to only that element clicked from search. Determining that element from
//other elements is little tricky. The idea here is, the element which has
//its child elements expanded to false is the actual element clicked from search. Scroll
//to that element.
let isThereChildItemsToExpand = this.props.data.childItems.filter((item: any) => {
return item.expanded == true;
});
if (isThereChildItemsToExpand.length == 0) {
setTimeout(() => {
let elem = ReactDOM.findDOMNode(this);
elem.scrollIntoView(false);
}, 0);
}

}
}

render() {
if ((this.props.libraryContainer.state?.hostingContext == HostingContextType.home)
&& this.props.data.hiddenInWorkspaceContext){
Expand Down

0 comments on commit 230f8bd

Please sign in to comment.