Navbar placement unreliable

Created on 30 January 2023, almost 2 years ago

Problem/Motivation

is_array() is no valid indicator to iterate over child elements when determining navbar placement.

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Daniel Kulbe Berlin

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

Comments & Activities

  • Issue created by @Daniel Kulbe
  • πŸ‡«πŸ‡·France mitsuko

    Thank you !

  • Had this problem too - an occasionally vanishing navbar. A similar fix in preprocess.inc solved it.

  • FTR the fix that worked, tho different is:

    /**
    * Implements template_preprocess_region().
    */
    
    function subthemename_preprocess_region(&$variables) {
    	$variables['attributes']['id'] = "region--$region";
    	if ($variables['region'] == 'navbar' && function_exists('render')) {
    		$variables['content_left'] = [];
    		$variables['content_center'] = [];
    		$variables['content_right'] = [];
    		foreach ($variables['elements'] as $id => $element) {
    			if (is_array($element)) {
    				$block = [];
            if (isset($element['#id'])) {
              $block = Block::load($element['#id']);
            }
            elseif (isset($element['#markup'])) {
              $block = Block::load($id);
            }
    				if ($block) {
              $navbar_alignment = $block->getThirdPartySetting('uikit_components', 'uikit_navbar_alignment', 'left');
              switch ($navbar_alignment) {
                case 'left':
                  $variables['content_left'][$id] = [
                    '#markup' => render($element),
                  ];
                  break;
    	            case 'center':
                  $variables['content_center'][$id] = [
                    '#markup' => render($element),
                  ];
                  break;
                case 'right':
                  $variables['content_right'][$id] = [
                    '#markup' => render($element),
                  ];
                  break;
              }
            }
          }
        }
      }
      else {
        uikit_preprocess_region($variables);
      }
    }
    
  • πŸ‡§πŸ‡ͺBelgium yazzbe

    Encountered a similar issue.

    The Navbar (top region) vanished after a cache rebuild on the homepage, reappeared on basic pages, but disappeared again on views pages. The Navbar's behavior was inconsistent.

    I manually applied patch #4 on Uikit 3.16 in Drupal 9.5.11, which resolved the issue.

    NB: Could this fix be included in a new release, as it addresses a critical/breaking website problem?

  • πŸ‡§πŸ‡ͺBelgium yazzbe

    Since this is a breaking bug, can I bump this issue to major?

    Can the fix be implemented in a stable D10 release?

    Many thanks

  • πŸ‡§πŸ‡ͺBelgium yazzbe
  • πŸ‡ΊπŸ‡ΈUnited States dobe

    I modified my preprocess.inc with the fixes from the patch and worked great! Thanks for helping find that bug.

  • Status changed to RTBC about 1 month ago
  • πŸ‡ΊπŸ‡ΈUnited States tkcent

    I can confirm patch #4 works as well for Drupal 10.3.6.

Production build 0.71.5 2024