Skip to content
This repository has been archived by the owner on Feb 27, 2020. It is now read-only.

feat(InteriorLeftNav): allow default open or collapsed #86

Merged
merged 1 commit into from
Jul 24, 2019
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
6 changes: 5 additions & 1 deletion src/components/InteriorLeftNav/InteriorLeftNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default class InteriorLeftNav extends Component {
className: PropTypes.string,
activeHref: PropTypes.string,
onToggle: PropTypes.func,
open: PropTypes.bool,
};

static defaultProps = {
Expand All @@ -21,13 +22,16 @@ export default class InteriorLeftNav extends Component {
state = {
activeHref:
this.props.activeHref || (window.location && window.location.pathname),
open: true,
open: typeof this.props.open !== 'undefined' ? this.props.open : true,
};

componentWillReceiveProps = nextProps => {
if (nextProps.activeHref) {
this.setState({ activeHref: nextProps.activeHref });
}
if (typeof nextProps.open != 'undefined') {
this.setState({ open: nextProps.open });
}
};

handleItemClick = (evt, href) => {
Expand Down