Skip to content

Firefly III: a personal finances manager

Menu fixes [skip ci]

James Cole4a2b01cd9af7
diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php
index cf9c8cef88..5b2088beab 100644
--- a/app/Support/Twig/General.php
+++ b/app/Support/Twig/General.php
@@ -92,18 +92,24 @@ class General extends Twig_Extension
$functions[] = new Twig_SimpleFunction(
'activeRoute', function ($context) {
- $args = func_get_args();
- $route = $args[1];
- $what = isset($args[2]) ? $args[2] : false;
+ $args = func_get_args();
+ $route = $args[1];
+ $what = isset($args[2]) ? $args[2] : false;
+ $strict = isset($args[3]) ? $args[3] : false;
$activeWhat = isset($context['what']) ? $context['what'] : false;
+
// activeRoute
if (!($what === false)) {
if ($what == $activeWhat && Route::getCurrentRoute()->getName() == $route) {
return 'active because-active-what';
}
} else {
- if (Route::getCurrentRoute()->getName() == $route) {
- return 'active because-route-matches';
+ if (!$strict && !(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
+ return 'active because-route-matches-non-strict';
+ } else {
+ if ($strict && Route::getCurrentRoute()->getName() == $route) {
+ return 'active because-route-matches-strict';
+ }
}
}
diff --git a/resources/twig/partials/menu.twig b/resources/twig/partials/menu.twig
index 91eec49241..da0704dfd3 100644
--- a/resources/twig/partials/menu.twig
+++ b/resources/twig/partials/menu.twig
@@ -90,7 +90,7 @@
<!-- /input-group -->
</li>
<li>
- <a class="{{ activeRoute('index') }}" href="{{ route('index') }}"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a>
+ <a class="{{ activeRoute('index',null,true) }}" href="{{ route('index') }}"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a>
</li>
<li class="{{ activeRoute('accounts.index') }}">
<a href="#"><i class="fa fa-credit-card fa-fw"></i> Accounts <span class="fa arrow"></span></a>