Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "remove(LibraryItem):forced scroll at componentDidMount" #234

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading