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

Issue fork navigation-3415455

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

plopesc created an issue. See original summary.

plopesc’s picture

Title: Navigation item IDs and classes are inconsistent in multilingual sites » [PP-1] Navigation item IDs and classes are inconsistent in multilingual sites
Status: Active » Postponed
Parent issue: » #3415311: Decouple from Toolbar module

Postponing on #3415311: Decouple from Toolbar module because presumably will be necessary to make changes on the tree manipulators.

akhil babu’s picture

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.

plopesc’s picture

Assigned: plopesc » Unassigned
m4olivei’s picture

Issue tags: +blocked
m4olivei’s picture

Status: Postponed » Active
Issue tags: -blocked
m4olivei’s picture

Title: [PP-1] Navigation item IDs and classes are inconsistent in multilingual sites » Navigation item IDs and classes are inconsistent in multilingual sites

plopesc’s picture

Status: Active » Needs review
m4olivei’s picture

Status: Needs review » Needs work
plopesc’s picture

Status: Needs work » Needs review

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

m4olivei’s picture

Status: Needs review » Reviewed & tested by the community

This looks great! Thanks @plopsec.

ckrina’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all for the work and help! Merged :D

Status: Fixed » Closed (fixed)

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