From 292d563cb47a9bd6e92fb4a0eacba433f7c22bdb Mon Sep 17 00:00:00 2001 From: squidfunk Date: Fri, 9 Feb 2024 13:30:31 +0700 Subject: [PATCH] Fixed navigation pruning when tabs + sections are active --- material/templates/partials/nav-item.html | 33 ++++++++++----- src/templates/partials/nav-item.html | 51 +++++++++++++++++------ 2 files changed, 61 insertions(+), 23 deletions(-) diff --git a/material/templates/partials/nav-item.html b/material/templates/partials/nav-item.html index d127bb16cce..08752b76050 100644 --- a/material/templates/partials/nav-item.html +++ b/material/templates/partials/nav-item.html @@ -53,20 +53,33 @@ {% endif %} {% endfor %} {% endif %} - {% set tabs = "navigation.tabs" in features %} - {% set sections = "navigation.sections" in features %} - {% if tabs and level == 1 or sections and tabs >= level - 1 %} - {% set class = class ~ " md-nav__item--section" %} - {% set is_section = true %} - {% elif not nav_item.active and "navigation.prune" in features %} - {% set class = class ~ " md-nav__item--pruned" %} - {% set is_pruned = true %} + {% if "navigation.tabs" in features %} + {% if level == 1 and nav_item.active %} + {% set class = class ~ " md-nav__item--section" %} + {% set is_section = true %} + {% endif %} + {% if "navigation.sections" in features %} + {% if level == 2 and nav_item.parent.active %} + {% set class = class ~ " md-nav__item--section" %} + {% set is_section = true %} + {% endif %} + {% endif %} + {% elif "navigation.sections" in features %} + {% if level == 1 %} + {% set class = class ~ " md-nav__item--section" %} + {% set is_section = true %} + {% endif %} + {% endif %} + {% if "navigation.prune" in features %} + {% if not is_section and not nav_item.active %} + {% set class = class ~ " md-nav__item--pruned" %} + {% set is_pruned = true %} + {% endif %} {% endif %}
  • {% if not is_pruned %} {% set checked = "checked" if nav_item.active %} - {% set is_expanded = "navigation.expand" in features %} - {% if is_expanded and not checked %} + {% if "navigation.expand" in features and not checked %} {% set indeterminate = "md-toggle--indeterminate" %} {% endif %} diff --git a/src/templates/partials/nav-item.html b/src/templates/partials/nav-item.html index 92d669a38b2..02568b29775 100644 --- a/src/templates/partials/nav-item.html +++ b/src/templates/partials/nav-item.html @@ -107,17 +107,43 @@ {% endfor %} {% endif %} - - {% set tabs = "navigation.tabs" in features %} - {% set sections = "navigation.sections" in features %} - {% if tabs and level == 1 or sections and tabs >= level - 1 %} - {% set class = class ~ " md-nav__item--section" %} - {% set is_section = true %} - - - {% elif not nav_item.active and "navigation.prune" in features %} - {% set class = class ~ " md-nav__item--pruned" %} - {% set is_pruned = true %} + + {% if "navigation.tabs" in features %} + + + {% if level == 1 and nav_item.active %} + {% set class = class ~ " md-nav__item--section" %} + {% set is_section = true %} + {% endif %} + + + {% if "navigation.sections" in features %} + + + {% if level == 2 and nav_item.parent.active %} + {% set class = class ~ " md-nav__item--section" %} + {% set is_section = true %} + {% endif %} + {% endif %} + + + {% elif "navigation.sections" in features %} + + + {% if level == 1 %} + {% set class = class ~ " md-nav__item--section" %} + {% set is_section = true %} + {% endif %} + {% endif %} + + + {% if "navigation.prune" in features %} + + + {% if not is_section and not nav_item.active %} + {% set class = class ~ " md-nav__item--pruned" %} + {% set is_pruned = true %} + {% endif %} {% endif %} @@ -126,8 +152,7 @@ {% set checked = "checked" if nav_item.active %} - {% set is_expanded = "navigation.expand" in features %} - {% if is_expanded and not checked %} + {% if "navigation.expand" in features and not checked %} {% set indeterminate = "md-toggle--indeterminate" %} {% endif %}