We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents dccc1f8 + 4d8d3be commit 905fc5cCopy full SHA for 905fc5c
menu_generator/menu.py
@@ -82,10 +82,20 @@ def _get_url(self, item_dict):
82
83
def _is_selected(self, item_dict):
84
"""
85
- Given a menu item dictionary, it returns true if `url` is on path.
+ Given a menu item dictionary, it returns true if `url` is on path,
86
+ unless the item is marked as a root, in which case returns true if `url` is part of path.
87
88
url = self._get_url(item_dict)
- return url == self.path
89
+ if self._is_root(item_dict):
90
+ return url in self.path
91
+ else:
92
+ return url == self.path
93
+
94
+ def _is_root(self, item_dict):
95
+ """
96
+ Given a menu item dictionary, it returns true if item is marked as a `root`.
97
98
+ return item_dict.get('root', False)
99
100
def _process_breadcrums(self, menu_list):
101
0 commit comments