chore: perfect scrollbar wrapper to maintain initial offset

This commit is contained in:
Roman Hotsiy 2018-07-31 15:36:30 +03:00
parent 35ba10f759
commit 5ebab5f942
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 9 additions and 0 deletions

View File

@ -27,7 +27,9 @@ export class PerfectScrollbar extends React.Component<{
private inst: PerfectScrollbarType;
componentDidMount() {
const offset = (this._container.parentElement && this._container.parentElement.scrollTop) || 0;
this.inst = new PerfectScrollbarConstructor(this._container, this.props.options || {});
this._container.scrollTo(0, offset);
}
componentDidUpdate() {

View File

@ -21,6 +21,13 @@ export class MenuItem extends React.Component<MenuItemProps> {
evt.stopPropagation();
};
componentDidMount() {
const item = this.props.item;
if (item.type !== 'group' && item.active) {
this.scrollIntoView();
}
}
componentDidUpdate() {
if (this.props.item.active) {
this.scrollIntoView();