Problem/Motivation

With #3503645: [D11.3] Contextual links: use dropdown, contextual links lose their destination query parameter.

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

grimreaper created an issue. See original summary.

grimreaper’s picture

app/core/modules/contextual/js/contextual.js

// Set the destination parameter on each of the contextual links.
    const destination = `destination=${Drupal.encodePath(
      Drupal.url(drupalSettings.path.currentPath + window.location.search),
    )}`;
    $contextual.find('.contextual-links a').each(function () {
      const url = this.getAttribute('href');
      const glue = url.includes('?') ? '&' : '?';
      this.setAttribute('href', url + glue + destination);
    });

And in app/themes/contrib/ui_suite_bootstrap/templates/system/links--contextual.html.twig:

<ul{{ attributes.addClass('dropdown-menu').removeClass('contextual-links') }}>

The contextual-links class had been removed to avoid side effect regarding Bootstrap dropdown state management and contextual link state management. Plus to avoid some styling effects.

grimreaper’s picture

Maybe more a Core issue #3576038: Do not rely on class to add destination parameter on contextual links to not rely on the contextual-links class.

grimreaper’s picture

Status: Active » Postponed

Waiting for reply on the Core issue.