-
Notifications
You must be signed in to change notification settings - Fork 295
/
SettingsLayout.tsx
44 lines (39 loc) · 1.04 KB
/
SettingsLayout.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// @flow
import React, { Component } from 'react';
import type { Node } from 'react';
import { observer } from 'mobx-react';
import styles from './SettingsLayout.scss';
type Props = {
children: Node,
menu: Node,
activePage: string,
};
@observer
export default class SettingsLayout extends Component<Props> {
scrollableDomElement: ?HTMLElement = null;
componentDidMount() {
this.scrollableDomElement = document.querySelector(
'.SettingsLayout_settingsPaneWrapper'
);
}
componentDidUpdate(prevProps: Props) {
const didActivePageChange = this.props.activePage !== prevProps.activePage;
if (
this.scrollableDomElement instanceof HTMLElement &&
didActivePageChange
) {
this.scrollableDomElement.scrollTop = 0;
}
}
render() {
const { menu, children } = this.props;
return (
<div className={styles.component}>
<div className={styles.settingsPaneWrapper}>
<div className={styles.settingsPane}>{children}</div>
</div>
{menu}
</div>
);
}
}