Olivero's book-tree.html.twig includes the following code:
{% if menu_level == 0 %}
<ul{{ attributes.addClass('menu', 'menu--level-' ~ (menu_level + 1)) }}>
{% else %}
<ul class='menu menu--level-' ~ (menu_level + 1)>
{% endif %}
The top-level <ul> element is fine, but sub-menus are trying to increment menu--level-X classes outside of twig brackets. The code should instead be:
{% if menu_level == 0 %}
<ul{{ attributes.addClass('menu', 'menu--level-' ~ (menu_level + 1)) }}>
{% else %}
<ul class='menu menu--level-{{ menu_level + 1 }}'>
{% endif %}
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | Screenshot 2021-03-23 at 10.29.05.png | 37.32 KB | gauravvvv |
| #7 | Screenshot 2021-03-23 at 10.27.46.png | 38.77 KB | gauravvvv |
| #5 | after-patch.png | 26.95 KB | bhumikavarshney |
| #5 | before-patch.png | 30.32 KB | bhumikavarshney |
| #2 | 3202808_02.patch | 645 bytes | andy-blum |
Comments
Comment #2
andy-blumComment #3
gauravvvv commentedGood catch @andy-blum, This is the right approach to Adding Level Number Class to Menu Items.
RTBC +1
Comment #4
Madhu kumar commentedPatch #2 applied cleanly and it is working well to adding Level Number Class to Menu Items.
Comment #5
bhumikavarshney commentedHi @andy-blum,
Patch in #2 applies cleanly and working fine for me.
Thanks
Comment #6
mherchel+1 RTBC on this.
It looks like this snuck in while massaging this template over from a
{% set %}statement in menu.html.twig. I verified that this does not occur in any other templates.Great catch and good fix!
Comment #7
gauravvvv commentedI have attached before and after patch screenshots. Reference to #3.
Comment #10
lauriiiThank you all for looking into this issue.
Posting screenshots of your codebase does not advance the issue, since the automated testing infrastructure tells us whether the patch applies correctly. I've removed the issue credit for the screenshots. In the future, you can get credit for issues by reading the issue to understand its purpose, and posting your review or testing of that purpose. Thank you!
See the issue credit guidelines for more information.
Committed 6ee786e and pushed to 9.2.x and 9.1.x. Thanks!