Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Page: Fix bug where multiple projects in the menu are "active"
Browse files Browse the repository at this point in the history
Navigating to /project/jquerycolor also marked /project/jquery
as active. This is now fixed.
  • Loading branch information
Krinkle committed Mar 30, 2017
1 parent 67fcb7d commit 2fb1458
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion inc/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ protected function getSelfPath() {
protected function getPageLink( $path, $label ) {
return
html_tag_open( 'li', array(
'class' => strpos( $this->getSelfPath(), $path ) === 0 ? 'active' : null,
// Apply "active" if path equals selfpath (/foo == /foo)
// or is contained within (/foo/123 == /foo), but not when
// it only starts with the same (/foobar != /foo).
'class' => ( $this->getSelfPath() === $path ||
( strpos( $this->getSelfPath(), "$path/" ) === 0 ) ) ? 'active' : null,
) )
. html_tag( 'a', array(
'href' => swarmpath( $path === 'home' ? '' : $path )
Expand Down

0 comments on commit 2fb1458

Please sign in to comment.