Menu: support non content menu links

Created on 21 October 2024, 26 days ago
Feature request
Status

Active

Version

1.0

Component

UI Icons Menu

Created by

🇫🇷France Grimreaper France 🇫🇷

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

Merge Requests

Comments & Activities

  • Issue created by @Grimreaper
  • 🇫🇷France Grimreaper France 🇫🇷
  • 🇫🇷France Grimreaper France 🇫🇷
  • Pipeline finished with Failed
    26 days ago
    Total: 167s
    #315928
  • 🇫🇷France Grimreaper France 🇫🇷

    To store overrides, it would be nice to be able to store into core.menu.static_menu_link_overrides.yml like core does, but the allowed keys of the overrides are hardcoded, not possible to extend currently.

    Maybe in a second time when icons in core will have more implementations.

    So I will currently store in a ui_icons_menu.settings.yml

  • 🇫🇷France Grimreaper France 🇫🇷

    When I try to add an element with:

    function ui_icons_menu_form_menu_link_edit_alter(&$form, FormStateInterface $form_state, $form_id) {
      $options = $form_state->getBuildInfo()['args'][0]->getOptions();
    
      $form['icon'] = [
        '#type'  => 'details',
        '#title' => t('Icon'),
      ];
    
      $form['icon']['icon'] = [
        '#type'          => 'icon_autocomplete',
        '#title'         => t('Icon'),
        '#default_value' => !empty($options['icon']['icon']) ? $options['icon']['icon'] : '',
        '#show_settings' => TRUE,
      ];
    
    

    I got an ajax error after selecting an icon.

    <em class="placeholder">LogicException</em>
    : The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution. in <em class="placeholder">Drupal\Core\Database\Connection-&gt;__sleep()</em>
    (line <em class="placeholder">1920</em>
    of <em class="placeholder">core/lib/Drupal/Core/Database/Connection.php</em>
    ). <pre class="backtrace">serialize(Array) (Line: 14)
    Drupal\Component\Serialization\PhpSerialize::encode(Array) (Line: 129)
    

    I trie to put the DependencySerializationTrait in multiple classes in ui_icons, not better.

    The problem comes from ui_icons/src/Element/IconAutocomplete.php::processIconAjaxForm

    $element['icon_id']['#ajax'] = [
          'callback' => [static::class, 'buildSettingsAjaxCallback'],
          'options' => [
            'query' => [
              'element_parents' => implode('/', $element['#array_parents']),
            ],
          ],
          // Autocomplete is already doing the ajax progress.
          'progress' => [
            'type' => 'none',
          ],
          'disable-refocus' => TRUE,
          'wrapper' => $ajax_wrapper_id,
          'effect' => 'none',
          // As we used autocomplete we want matching events.
          // @todo check for too early errors related to change.
          'event' => 'autocompleteclose change',
        ];
    
  • Pipeline finished with Failed
    25 days ago
    Total: 311s
    #316086
  • 🇫🇷France Grimreaper France 🇫🇷

    Hi,

    Except for the AJAX problem, MR is ok for review.

    I have not executed code quality tools for now as it is more in a POC state waiting for maintainers feedback.

  • Pipeline finished with Failed
    25 days ago
    Total: 164s
    #316938
  • 🇫🇷France Grimreaper France 🇫🇷

    Wondering about translatability of the alt settings in case of YAML declared links.

Production build 0.71.5 2024