A page only has children when it is active

I have a running installation of Django CMS 3.8. In the project, there is a page on the top level that has three children. I want the navbar link for this page to be a dropdown menu. When I’m on the page itself Django CMS correctly recognizes that this page has children and the dropdown menu appears. However when that page is not the active one, it seems to not have any children and no dropdown menu appears.
This is my template code:

{% for child in children %}
   <li class="nav-item {% if child.ancestor %}ancestor{% endif %}
       {% if child.selected %} active{% endif %}
       {% if child.children %} dropdown{% endif %}">
       {% if child.children %}
        <a class="nav-link dropdown-toggle" href="{{ child.get_absolute_url }}" id="dropdownMenuLink"    role="button" data-bs-toggle="dropdown" aria-expanded="false">
               {{ child.get_menu_title }}
           </a>
           <ul class="dropdown-menu bg-primary" aria-labelledby="dropdownMenuLink">
               {% show_menu from_level to_level extra_inactive extra_active template "" "" child %}
           </ul>
       {% else %}
           <a class="nav-link" href="{{ child.get_absolute_url }}">{{ child.get_menu_title }}</a>
       {% endif %}
   </li>
   {% if class and forloop.last and not forloop.parentloop %}{% endif %}
{% endfor %}