Remove undefined item condition in primary menu template

Created on 15 May 2024, about 1 month ago
Updated 20 June 2024, 8 days ago

Problem/Motivation

It doesn't seem to be causing errors, but menu primary template uses an undefined item variable. It seems to have been copied from a section of code in the for item in items loop a little lower down the file.

  {% if item.url.isRouted and item.url.routeName == '<nolink>' %}
    {% set menu_item_type = 'nolink' %}
  {% elseif item.url.isRouted and item.url.routeName == '<button>' %}
    {% set menu_item_type = 'button' %}
  {% else %}
    {% set menu_item_type = 'link' %}
  {% endif %}

Without the item variable set, the condition above means it will always set the class to link.

Steps to reproduce

Compare L38-L45 to L86-L93. Note that former has no defined item variable.

Proposed resolution

Options:

  1. Remove the condition and just set the class to link
  2. Move the condition and the affected initial element to within the for loop. Though, I think the later is prevented by the need to output the initial elements before the for loop.

Remaining tasks

See if a similar issue exists in other menu templates.

*** Recommend just removing the extra code and going with only the part in the else that is actually doing something.

{% set menu_item_type = 'link' %}

πŸ“Œ Task
Status

Fixed

Version

3.7

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jcandan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024