When using the Sticky option on Top Bar, the stickiness only kicks in at medium screen size. To make it sticky on small screens too you have to use data-option="stickOn:small". I've rolled a patch to fix this.

The patch also includes a couple of other tweaks and enhancements:

  • An option to include the language switcher in the Top Bar, if the language module is enabled.
  • Tidied up zurb_foundation.settings.yml and added zurb_foundation.schema.yml (I did this while trying to get configuration translation to work so that the Menu text setting could be translated. I didn't manage to get that working but I think the yml file changes are good in any case.
  • A couple of coding standards fixes flagged up by code sniffer.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Peacog created an issue. See original summary.

kevinquillen’s picture

FileSize
12.24 KB

I made some tweaks, removed some commented code, rerolled. Let me know what you think.

FYI I tend to stick to the use ... convention instead of the full name typehint.

Peacog’s picture

That looks good. The re-rolled patch doesn't include the schema.yml file, but it's not needed for the moment, until I figure out how to translate the theme configuration settings.

kevinquillen’s picture

That's odd... I thought I saw it in the list when creating the patch.

samuel.mortenson’s picture

Re-rolling/reviewing this now...

samuel.mortenson’s picture

FileSize
9.59 KB

Here's a re-rolled patch (of #2). The only code I changed was the bit that rendered the language block - my main issue with it was that it required the user to have already placed/created the Language Switcher Block somewhere, and when they placed it used the machine name "languageswitcher". This change accesses and renders the Block Plugin directly, without making any assumptions about the user's environment.

diff -u b/inc/menu.inc b/inc/menu.inc
--- b/inc/menu.inc
+++ b/inc/menu.inc
@@ -141,12 +142,11 @@
     // Embed the Language switcher inside the Top Bar.
     if (\Drupal::moduleHandler()->moduleExists('language')) {
       if (theme_get_setting('zurb_foundation_top_bar_languageswitcher')) {
-        $block = \Drupal\block\Entity\Block::load('languageswitcher');
-        if ($block) {
-          $variables['top_bar_languageswitcher'] = \Drupal::entityTypeManager()
-            ->getViewBuilder('block')
-            ->view($block);
-        }
+        /** @var \Drupal\Core\Block\BlockManager $block_plugin_manager */
+        $block_plugin_manager = \Drupal::service('plugin.manager.block');
+        /** @var \Drupal\language\Plugin\Block\LanguageBlock $language_block */
+        $language_block = $block_plugin_manager->createInstance('language_block:language_interface', []);
+        $variables['top_bar_languageswitcher'] = $language_block->build();
       }
     }
   }
Peacog’s picture

That's much better, and it all works perfectly. Thanks.

  • samuel.mortenson committed 5a60f8d on 8.x-6.x
    Issue #2684161 by Peacog, kevinquillen, samuel.mortenson: Make Top Bar...
samuel.mortenson’s picture

Status: Needs review » Fixed

Committed, this was blocking some other setting work I wanted to do on the branch. Thanks for the (informal) review @Peacog!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.