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.

  • grimreaper committed bc46188f on 5.2.x
    fix: #3575786 Contextual links: lost query parameters
    
    By: grimreaper
    
grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Postponed » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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