Answers.Body: <p>This is working for me.</p>
  <p>Module.php</p>
  <pre><code>        Event::on(Cp::class, Cp::EVENT_REGISTER_CP_NAV_ITEMS, function (RegisterCpNavItemsEvent $event) {
              $event-&gt;navItems[] = [
                  'url' =&gt; 'modules/video',
                  'label' =&gt; 'Video-Converter',
                  'icon' =&gt; '@modules/icon-mask.svg',
  
                  'subnav' =&gt; [
                      'inhex' =&gt; [
                          'url' =&gt; 'modules/video/index',
                          'label' =&gt; 'Project-Video',
                      ],
                      'old' =&gt; [
                          'url' =&gt; 'modules/video/old',
                          'label' =&gt; 'Old Projects',
                      ],
                  ]
              ];
          });
  </code></pre>
  <p>And in the templates I am using e.g.</p>
  <pre><code>{% extends '_layouts/cp' %}
  
  {% set title = 'Old Projects' %}
  {% set selectedSubnavItem = 'old' %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-15T19:11:28.650Z
Answers.LastActivityDate: 2021-03-16T12:24:05.607Z
Answers.LastEditDate: 2021-03-16T12:24:05.607Z
Answers.UserDisplayName: Volker Andres
Body: <p>I have a problem with setting up a CP navigation for my <strong>module</strong>.</p>
  <p>In module's init() I declared the following:</p>
  <pre class="lang-php prettyprint-override"><code>Event::on(
      Cp::class,
      Cp::EVENT_REGISTER_CP_NAV_ITEMS,
      function (RegisterCpNavItemsEvent $event) {
          $event-&gt;navItems[] = [
              'url' =&gt; 'asset-checker-module/broken-links',
              'label' =&gt; 'Checker',
              'subnav' =&gt; [
                  'broken-links' =&gt; [
                      'url' =&gt; 'asset-checker-module/broken-links',
                      'label' =&gt; 'Fehlerhafte Links'
                  ],
                  'unused-assets' =&gt; [
                      'url' =&gt; 'asset-checker-module/unused-assets',
                      'label' =&gt; 'Nicht verwendete Dateien'
                  ]
              ]
          ];
      }
  );
  </code></pre>
  <p>So I see my main navigation item, when I click on it, the subnavigation gets expanded, the first element is active. But when I click on the second item, parent item gets collapsed.</p>
  <p>I tried to fix it by setting <code>selectedSubnavItem</code> in my template, it did not help.</p>
  <p>Any ideas?</p>
  <hr />
  <p>Running Craft 3.2.7.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-03-15T19:03:48.660Z
Comments.Text: Having the same issue
Comments.UserDisplayName: Volker Andres
Tags: <control-panel><modules><plugin-navigation>
Title: Module's control panel sub-navigation is not working properly
ThreadText: # Module's control panel sub-navigation is not working properly
  
  (Asked by: username_0 on 2020-08-20)
  
  I have a problem with setting up a CP navigation for my **module**.
  
  In module's init() I declared the following:
  
  ```php
  Event::on(
      Cp::class,
      Cp::EVENT_REGISTER_CP_NAV_ITEMS,
      function (RegisterCpNavItemsEvent $event) {
          $event->navItems[] = [
              'url' => 'asset-checker-module/broken-links',
              'label' => 'Checker',
              'subnav' => [
                  'broken-links' => [
                      'url' => 'asset-checker-module/broken-links',
                      'label' => 'Fehlerhafte Links'
                  ],
                  'unused-assets' => [
                      'url' => 'asset-checker-module/unused-assets',
                      'label' => 'Nicht verwendete Dateien'
                  ]
              ]
          ];
      }
  );
  
  ```
  
  So I see my main navigation item, when I click on it, the subnavigation gets expanded, the first element is active. But when I click on the second item, parent item gets collapsed.
  
  I tried to fix it by setting `selectedSubnavItem` in my template, it did not help.
  
  Any ideas?
  
  ---
  
  Running Craft 3.2.7.
  
  **Tags:** control-panel, modules, plugin-navigation
  
  > **Comments:**
  > **username_1**: Having the same issue  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-03-15. Score: 1 | Accepted answer
  
  This is working for me.
  
  Module.php
  
  ```
          Event::on(Cp::class, Cp::EVENT_REGISTER_CP_NAV_ITEMS, function (RegisterCpNavItemsEvent $event) {
              $event->navItems[] = [
                  'url' => 'modules/video',
                  'label' => 'Video-Converter',
                  'icon' => '@modules/icon-mask.svg',
  
                  'subnav' => [
                      'inhex' => [
                          'url' => 'modules/video/index',
                          'label' => 'Project-Video',
                      ],
                      'old' => [
                          'url' => 'modules/video/old',
                          'label' => 'Old Projects',
                      ],
                  ]
              ];
          });
  
  ```
  
  And in the templates I am using e.g.
  
  ```
  {% extends '_layouts/cp' %}
  
  {% set title = 'Old Projects' %}
  {% set selectedSubnavItem = 'old' %}
  
  ```
  
  
  ---
  
  