Skip to content

Commit 9fa7335

Browse files
committed
Open menus for ancestor namespaces containing active package
1 parent a93b9ba commit 9fa7335

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

tools/docs/www/src/side_menu.jsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ import ChevronRightIcon from '@material-ui/icons/ChevronRight';
3434
import Logo from './logo.jsx';
3535

3636

37+
// VARIABLES //
38+
39+
const RE_FORWARD_SLASH = /\//g;
40+
41+
3742
// MAIN //
3843

3944
class MenuBar extends Component {
@@ -50,9 +55,16 @@ class MenuBar extends Component {
5055
const history = this.props.history;
5156
const pathname = history.location.pathname;
5257
if ( !pathname.endsWith( this.state.activePkg ) ) {
53-
this.setState({
54-
activePkg: pathname.substring( pathname.indexOf( '@stdlib' ) )
55-
});
58+
const packagePath = pathname.substring( pathname.indexOf( '@stdlib' ) );
59+
const newState = {
60+
[ packagePath ]: true,
61+
activePkg: packagePath
62+
};
63+
let match;
64+
while ( ( match = RE_FORWARD_SLASH.exec( packagePath) ) !== null ) {
65+
newState[ packagePath.substring( 0, match.index ) ] = true;
66+
}
67+
this.setState( newState );
5668
}
5769
}
5870

0 commit comments

Comments
 (0)