fix: Sidebar links unexpand

closes #1044
This commit is contained in:
Tom Moor 2019-10-13 16:15:42 -07:00
parent 766a52f10e
commit 21af0bd8be
2 changed files with 4 additions and 6 deletions

View File

@ -72,7 +72,7 @@ class DocumentLink extends React.Component<Props> {
pathname: node.url,
state: { title: node.title },
}}
expanded={showChildren}
expanded={showChildren ? true : undefined}
label={node.title}
depth={depth}
exact={false}

View File

@ -26,16 +26,12 @@ type Props = {
@observer
class SidebarLink extends React.Component<Props> {
@observable expanded: boolean;
@observable expanded: ?boolean = this.props.expanded;
style = {
paddingLeft: `${(this.props.depth || 0) * 16 + 16}px`,
};
componentDidMount() {
if (this.props.expanded) this.handleExpand();
}
componentWillReceiveProps(nextProps: Props) {
if (nextProps.expanded !== undefined) {
this.expanded = nextProps.expanded;
@ -45,6 +41,8 @@ class SidebarLink extends React.Component<Props> {
@action
handleClick = (ev: SyntheticEvent<>) => {
ev.preventDefault();
ev.stopPropagation();
this.expanded = !this.expanded;
};