@ -72,7 +72,7 @@ class DocumentLink extends React.Component<Props> {
|
|||||||
pathname: node.url,
|
pathname: node.url,
|
||||||
state: { title: node.title },
|
state: { title: node.title },
|
||||||
}}
|
}}
|
||||||
expanded={showChildren}
|
expanded={showChildren ? true : undefined}
|
||||||
label={node.title}
|
label={node.title}
|
||||||
depth={depth}
|
depth={depth}
|
||||||
exact={false}
|
exact={false}
|
||||||
|
@ -26,16 +26,12 @@ type Props = {
|
|||||||
|
|
||||||
@observer
|
@observer
|
||||||
class SidebarLink extends React.Component<Props> {
|
class SidebarLink extends React.Component<Props> {
|
||||||
@observable expanded: boolean;
|
@observable expanded: ?boolean = this.props.expanded;
|
||||||
|
|
||||||
style = {
|
style = {
|
||||||
paddingLeft: `${(this.props.depth || 0) * 16 + 16}px`,
|
paddingLeft: `${(this.props.depth || 0) * 16 + 16}px`,
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
if (this.props.expanded) this.handleExpand();
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps: Props) {
|
componentWillReceiveProps(nextProps: Props) {
|
||||||
if (nextProps.expanded !== undefined) {
|
if (nextProps.expanded !== undefined) {
|
||||||
this.expanded = nextProps.expanded;
|
this.expanded = nextProps.expanded;
|
||||||
@ -45,6 +41,8 @@ class SidebarLink extends React.Component<Props> {
|
|||||||
@action
|
@action
|
||||||
handleClick = (ev: SyntheticEvent<>) => {
|
handleClick = (ev: SyntheticEvent<>) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
ev.stopPropagation();
|
||||||
|
|
||||||
this.expanded = !this.expanded;
|
this.expanded = !this.expanded;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user