Icons missing in experimental sidebar navigation (language bug)

Created on 19 October 2023, 8 months ago
Updated 21 October 2023, 8 months ago

Problem/Motivation

If you use a language other than English, the class name will be adjusted according to the link title.

Steps to reproduce

Change the interface language (tested with french and german)

Proposed resolution

We use the item.title as visual modifier in gin/templates/menu-region--middle.html.twig:15
and for the buttons in
gin/templates/menu-region--middle.html.twig:28

We have to use another method.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Component

Code

Created by

🇩🇪Germany gnuschichten

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

Comments & Activities

  • Issue created by @gnuschichten
  • 🇩🇪Germany gnuschichten

    A solution in the frontend would be an attribute selector, like [href ~="foo"]

    Since the url is the same in all languages. But that's not elegant. Twig filters don't work here and are not a good solution.
    {{ url | split('/') | last }}

    I think this should be solved via a variable in the module if you don't want me to throw javascript on it. :)

  • 🇫🇷France NicolasGraph Strasbourg

    Not sure that's the best way to do but I was able to locally fix the issue by replacing toolbar-link--{{item.title|clean_class }} by toolbar-link--{{item.title.getUntranslatedString()|clean_class }} in templates.

  • 🇫🇷France NicolasGraph Strasbourg

    Here is the patch I talked previously, however, in my case, .getUntranslatedString() returns NULL for some links title, so in fact some icons are still missing. Falling back to the title works for a few of them, but still not ideal.

  • 🇫🇷France pbonnefoi

    @NicolasGraph I tried the patch but some icons are still missing (using french language)

  • First commit to issue fork.
  • @saschaeggi opened merge request.
  • Status changed to Needs review 8 months ago
  • 🇨🇭Switzerland saschaeggi Zurich
  • Status changed to Needs work 8 months ago
  • 🇨🇭Switzerland saschaeggi Zurich
  • 🇨🇭Switzerland saschaeggi Zurich

    We'll need to add safe classes maybe based on the item id in getNavigationAdminMenuItems() to expose them to the twig template.

  • Status changed to Needs review 8 months ago
  • 🇨🇭Switzerland saschaeggi Zurich

    Added the class to content menus. This needs another review :)

  • 🇫🇷France pbonnefoi

    @saschaeggi I saw your commit but that did not solve the translation issue. In my last commit I changed to use the routing instead of the title to create the class. It's less likely to change than a title I think so more robust (despite having not so beautiful classes). I also made changes on Create and Content navigation to make it consistent.
    Works fine on my version (But still having sprite issues for some reasons, but I think that is another problem).

    I might find a better solution later with creating a custom manipulator. It's funny I saw an interesting solution on my own question asked on Stackexchange posted 7 years ago :-D (https://drupal.stackexchange.com/questions/201903/programmatically-get-m...)

    Anyway, let me know what you think and if I can help on other things.

  • Assigned to pbonnefoi
  • 🇫🇷France NicolasGraph Strasbourg

    This seems a quite good approach to me and it does work on a fresh install of mine.
    I'm just wondering: why to use a twig filter to build and clean the class instead of just doing it properly in the GinNavigation service ?

  • Issue was unassigned.
  • 🇨🇭Switzerland saschaeggi Zurich

    @NicolasGraph @pbonnefoi I've pushed a change where we add the pluginId as class in php instead.

    This should now be ready for a review.

  • Status changed to RTBC 8 months ago
  • 🇫🇷France NicolasGraph Strasbourg

    I suggested a comment update ; otherwise, it seems good enough to me to go forward.
    Thank you both!

  • Status changed to Fixed 8 months ago
  • 🇨🇭Switzerland saschaeggi Zurich

    Thanks @NicolasGraph & @pbonnefoi

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

Production build 0.69.0 2024