Navigation item IDs and classes are inconsistent in multilingual sites

Created on 18 January 2024, about 1 year ago
Updated 6 March 2024, 11 months ago

Problem/Motivation

Item IDs and classes are being generated directly from the item title in some scenarios.
That leads to inconsistent values that makes unpredictable the HTML markup of the navigation bar.

Steps to reproduce

Install a fresh Umami site and enable Navigation module
Go to the home page and confirm that Shortcuts item has a star icon (Class is .toolbar-button--shortcuts)
Go to the Spanish homepage https://mysite.example/es
Confirm that Shortcuts icon is broken (Class is .toolbar-button--atajos)

It happens not only in this menu item, but this is the most visible situation. Other menu items are being altered as well by the language switch.

Proposed resolution

Find a way to have consistent navigation items properties across the different languages in multilingual sites

Remaining tasks

Fix issue
Add tests

User interface changes

None

API changes

None

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇪🇸Spain plopesc Valladolid

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

Merge Requests

Comments & Activities

  • Issue created by @plopesc
  • Status changed to Postponed about 1 year ago
  • 🇪🇸Spain plopesc Valladolid

    Postponing on 📌 Decouple from Toolbar module Needs review because presumably will be necessary to make changes on the tree manipulators.

  • 🇮🇳India Akhil Babu Chengannur

    Shortcut icon will also break if the title of the 'Shortcut' block is modified. This happens because ShortcutsNavigationBlock uses the title of the block as the class name. When the title changes, the class name also changes, which breaks the style.

      /**
       * {@inheritdoc}
       */
      public function build(): array {
        $shortcuts_items = [
          [
            'title' => $this->configuration['label'],
            'class' => $this->configuration['label'],
          ],
        ];
    
    

    One solution is to use the 'id' of the block as the class name instead of the title. However, the navigation UI permits adding multiple blocks of the same type to the sidebar. If a user adds a second 'Shortcuts' block, the id of that block would be 'shortcuts_1,' and it will break the icon of the second block.

  • Issue was unassigned.
  • 🇨🇦Canada m4olivei Grimsby, ON
  • Status changed to Active about 1 year ago
  • 🇨🇦Canada m4olivei Grimsby, ON

    Marking unblocked since 🐛 Error: Call to a member function replace() on null Needs review was merged.

  • 🇨🇦Canada m4olivei Grimsby, ON
  • Merge request !172Issue #3415455: Normalize menu IDs → (Merged) created by plopesc
  • Status changed to Needs review about 1 year ago
  • Pipeline finished with Success
    about 1 year ago
    Total: 161s
    #86211
  • Status changed to Needs work 12 months ago
  • 🇨🇦Canada m4olivei Grimsby, ON
  • Status changed to Needs review 12 months ago
  • 🇪🇸Spain plopesc Valladolid

    Requested changes addressed. I think it's ready for review.

  • Pipeline finished with Failed
    12 months ago
    Total: 6349s
    #99582
  • Pipeline finished with Success
    12 months ago
    Total: 151s
    #100369
  • Status changed to RTBC 12 months ago
  • 🇨🇦Canada m4olivei Grimsby, ON

    This looks great! Thanks @plopsec.

  • 🇪🇸Spain ckrina Barcelona

    Thanks all for the work and help! Merged :D

  • Pipeline finished with Success
    12 months ago
    Total: 176s
    #100770
  • Status changed to Fixed 12 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Pipeline finished with Success
    10 months ago
    #133288
  • Pipeline finished with Success
    10 months ago
    Total: 246s
    #136098
  • Pipeline finished with Success
    8 months ago
    Total: 291s
    #191966
  • Pipeline finished with Success
    8 months ago
    Total: 281s
    #191971
  • Pipeline finished with Success
    8 months ago
    Total: 1007s
    #203276
  • Pipeline finished with Skipped
    8 months ago
    #203285
  • Pipeline finished with Success
    8 months ago
    Total: 808s
    #204014
  • Pipeline finished with Success
    8 months ago
    Total: 137s
    #205396
  • Pipeline finished with Success
    8 months ago
    Total: 136s
    #205397
Production build 0.71.5 2024