Problem/Motivation

Currently local actions do not provide a destination which results in an inconsistent UX because users expect to return to the page where they clicked the button.

Steps to reproduce:

  1. Sign in as an administrator
  2. Go to admin/people
  3. Click the 'Add user' local action
  4. Fill out the form to add a new user.
  5. You get 'stuck' on the Add user page, when most people would have wanted to return to the People listing.

Proposed resolution

Provide a local action option parameter so the user is 'returned' to the page from where the click on the action link originated.

Remaining tasks

  • Fix deprecation (#36 point 4)
  • Expand documentation in menu.api.php
  • Expand functionality allowing to set a destination? (see #36 point 5)
  • Review
  • Create change record

User interface changes

When the option is provided in a specific local action *.links.action.yml, the user who clicks the action will be redirected to the destination parameter path. @alexpott in comment #36.5 proposes that the destination route could be specified in the yml entry.

API changes

There is a new option 'add_destination' available for local action plugins. @alexpott in comment #36.5 proposes that option should have the form: destination: some.route_name allowing developers to specify any route for the destination.

Data model changes

None.

Release notes snippet

Needs change record.

CommentFileSizeAuthor
#54 interdiff_51-54.txt2.26 KBmrinalini9
#54 1344902-54.patch9.92 KBmrinalini9
#51 interdiff_50-51.txt626 bytesNikhil_110
#51 1344902-51.patch9.91 KBNikhil_110
#50 1344902-50.patch9.83 KBsahil.goyal
#49 1344902-49.patch9.56 KBDieterHolvoet
#45 interdiff_34-45.txt5 KBchrisolof
#45 action-links-with-destination-1344902-45.patch9.55 KBchrisolof
#34 interdiff.txt1.77 KBbotanic_spark
#34 action-links-with-destination-1344902-34.patch9.3 KBbotanic_spark
#30 action-links-with-destination-1344902-30.patch9.32 KBbotanic_spark
#29 action-links-with-destination-ci-debug.patch11.44 KBbotanic_spark
#28 action-links-with-destination-1344902-28.patch9.23 KBbotanic_spark
#25 interdiff.txt3.07 KBbotanic_spark
#25 action-links-with-destination-1344902-25.patch9.23 KBbotanic_spark
#20 interdiff.txt3.28 KBbotanic_spark
#20 action-links-with-destination-1344902-20.patch7.18 KBbotanic_spark
#15 interdiff.txt4.48 KBbotanic_spark
#15 action-links-with-destination-1344902-15.patch5.73 KBbotanic_spark
#12 action-links-with-destination-1344902-12.patch5.47 KBbotanic_spark
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

This can be implemented in a custom module with the following code:

function custom_preprocess_menu_local_action(&$variables) {
  $link = &$variables['element']['#link'];
  $link += array('localized_options' => array());
  $link['localized_options'] += array('query' => array());
  $link['localized_options']['query'] += drupal_get_destination();
}

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

joelstein’s picture

Issue summary: View changes

I agree!

Btw, here's one way to do it, for anyone who stumbles on this:

https://mushtaqtahir.com/blog/12/drupal-8-add-redirect-destination-in-ac...

joelstein’s picture

Actually, the MenuLinkAdd class does this (and only this), so all that's needed in your MODULE.links.action.yml file is to define the 'class' option to this MenuLinkAdd class, like so:

custom.add_article:
  route_name: node.add
  title: 'Add article'
  route_parameters:
    node_type: 'article'
  class: \Drupal\menu_ui\Plugin\Menu\LocalAction\MenuLinkAdd
  appears_on:
    - view.articles.page_1

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

gordon’s picture

Looking at #6 does it exactly as required. But I think it is not right for other modules to freeload on the menu_ui module. I think that this should be moved (ultimately) to the class name of something like Drupal\Core\Menu\LocalActionAppendDestination so that any module can used this without fear of being broken in a future release.

This should not be renamed, as it will break a peoples modules which already use this. We should copy to the new path, and mark MenuLinkAdd as depreciated.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

seanB’s picture

botanic_spark’s picture

The idea is to update the default Action Link plugin to support destination parameter.
In the definition of action links (yml) new parameter is introduced - add_destination: true.
If this is added, destination is appended to the action link button.

After discussion with @alexpott, it was suggested that action links should not have destination parameters by default, due to so many security issues that were related to destination itself.
We are keeping the default functionality as it was, but there is a possibility to control it in the appropriate yml file.

Original class is marked as deprecated.

Tests are added.

botanic_spark’s picture

Assigned: Unassigned » botanic_spark
Status: Active » Needs review
phenaproxima’s picture

Status: Needs review » Needs work

This makes a lot of sense to me and I think it's a nice change. I think we may need explicit tests of LocalActionDefault, but the stuff added here may suffice. I'll leave that choice up to a committer.

  1. +++ b/core/lib/Drupal/Core/Menu/LocalActionDefault.php
    @@ -26,6 +27,13 @@ class LocalActionDefault extends PluginBase implements LocalActionInterface, Con
    +  private $redirectDestination;
    

    Needs to be protected.

  2. +++ b/core/lib/Drupal/Core/Menu/LocalActionDefault.php
    @@ -38,10 +46,11 @@ class LocalActionDefault extends PluginBase implements LocalActionInterface, Con
    +  public function __construct(array $configuration, $plugin_id, $plugin_definition, RouteProviderInterface $route_provider, RedirectDestinationInterface $redirect_destination) {
         parent::__construct($configuration, $plugin_id, $plugin_definition);
     
         $this->routeProvider = $route_provider;
    +    $this->redirectDestination = $redirect_destination;
    

    We'll need to default $rediect_destination to NULL and pull it out of \Drupal::service() if so. See \Drupal\config\Controller\ConfigController::__construct() for an example of this.

  3. +++ b/core/lib/Drupal/Core/Menu/LocalActionDefault.php
    @@ -119,7 +129,14 @@ public function getRouteParameters(RouteMatchInterface $route_match) {
    +    if (isset($definition['add_destination']) && $definition['add_destination'] === TRUE) {
    

    I think this should probably be an option. Also, we can make this !empty($options['add_destination']), which covers both the isset() and truthy checks.

  4. +++ b/core/modules/menu_ui/menu_ui.links.action.yml
    @@ -1,7 +1,7 @@
    +  add_destination: true
       appears_on:
         - entity.menu.edit_form
    

    This will need to be something like:

    options:
      add_destination: true
    
  5. +++ b/core/modules/menu_ui/src/Plugin/Menu/LocalAction/MenuLinkAdd.php
    @@ -2,6 +2,8 @@
    +@trigger_error('The ' . __NAMESPACE__ . '\MenuLinkAdd is deprecated in drupal:8.8.0. Instead, use `add_destination: true` parameter in declaration of action links.', E_USER_DEPRECATED);
    

    s/parameter/option/

    We will also need a change record for this, but don't worry about filing that, someone else can take care of it. Just pointing it out.

  6. +++ b/core/modules/menu_ui/src/Plugin/Menu/LocalAction/MenuLinkAdd.php
    @@ -10,6 +12,9 @@
    + * @deprecated in drupal:8.8.0. Instead, use `add_destination: true` parameter
    

    s/parameter/option/

  7. +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
    @@ -275,10 +275,22 @@ public function doMenuTests() {
    +    // Test destination parameter in the url.
    

    Supernit: 'url' --> URL

  8. +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
    @@ -275,10 +275,22 @@ public function doMenuTests() {
    +    $this->assertUrl('admin/structure/menu/manage/' . $menu_name . '/add?destination=' . $destination);
    

    Looks like assertUrl() is deprecated, it seems we should use $this->assertSession()->addressEquals() instead.

  9. +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
    @@ -275,10 +275,22 @@ public function doMenuTests() {
    +    // Test destination redirect.
    +    $this->assertUrl($destination);
    

    Same here.

botanic_spark’s picture

@phenaproxima Thanks for the quick review!

Here are the updates based on your comments.

botanic_spark’s picture

Status: Needs work » Needs review
phenaproxima’s picture

Thanks! Changes look good. Since this change impacts a core class that's outside of any particular module's namespace, marking for framework manager review.

The last submitted patch, 12: action-links-with-destination-1344902-12.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 15: action-links-with-destination-1344902-15.patch, failed testing. View results

botanic_spark’s picture

botanic_spark’s picture

Status: Needs work » Needs review
seanB’s picture

Version: 8.6.x-dev » 8.8.x-dev
Status: Needs review » Needs work

The test is probably failing because LocalActionDefaultTest needs the new parameter passed in setupLocalActionDefault.

  1. +++ b/core/lib/Drupal/Core/Menu/LocalActionDefault.php
    @@ -38,10 +46,15 @@ class LocalActionDefault extends PluginBase implements LocalActionInterface, Con
    +  public function __construct(array $configuration, $plugin_id, $plugin_definition, RouteProviderInterface $route_provider, RedirectDestinationInterface $redirect_destination) {
    

    The new $redirect_destination parameter still needs to be documented on the method.

  2. +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
    @@ -275,10 +275,22 @@ public function doMenuTests() {
    +    $destination = Url::fromRoute('entity.menu.edit_form', ['menu' => $menu_name])->toString();
    

    We should probably not use Url::fromRoute()->toString() since that adds the subdirectory. It is probably also why the test fails.

seanB’s picture

Status: Needs work » Needs review

We cross posted, seems everything is addressed. Let's see if the tests pass and wait for framework manager review.

Status: Needs review » Needs work

The last submitted patch, 20: action-links-with-destination-1344902-20.patch, failed testing. View results

botanic_spark’s picture

botanic_spark’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 25: action-links-with-destination-1344902-25.patch, failed testing. View results

botanic_spark’s picture

botanic_spark’s picture

Running single test to confirm it's passing.

botanic_spark’s picture

I think this is the good one :)

botanic_spark’s picture

Status: Needs work » Needs review
phenaproxima’s picture

Status: Needs review » Needs work

I think this looks pretty good, honestly! Nice work!

  1. +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
    @@ -275,10 +275,19 @@ public function doMenuTests() {
    +    $this->assertSession()->linkByHrefExists('admin/structure/menu/manage/' . $menu_name . '/add?destination=' . Url::fromRoute('entity.menu.edit_form', ['menu' => $menu_name])->toString(), 0, "The add menu link button URL does not have destination parameter");
    

    Nit: It looks like we use the Url::fromRoute('entity.menu.edit_form', ['menu' => $menu_name'])->toString() URL multiple times in the test. Can we do something like this, for clarity:

    $expected_destination = Url::fromRoute('entity.menu.edit_form', ['menu => $menu])->toString();
    $this->assertSession()->linkByHrefExists("admin/structure/menu/manage/$menu_name/add?destination=$expected_destination");
    
  2. +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
    @@ -275,10 +275,19 @@ public function doMenuTests() {
    +    // Clink on the link.
    

    "Clink"? :)

  3. +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
    @@ -275,10 +275,19 @@ public function doMenuTests() {
    +    // Create link.
    

    Nit: I don't think comment adds much :)

  4. +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
    @@ -275,10 +275,19 @@ public function doMenuTests() {
         $this->assertUrl(Url::fromRoute('entity.menu.edit_form', ['menu' => $menu_name]));
    

    If we do the thing I suggested above, this can become $this->assertUrl($expected_destination).

botanic_spark’s picture

@phenaproxima Thanks for the review!
I can surely put destination in the variable (that is how i initially did it, but then removed it :D )

However, point 4. would not work with the variable in that way, because toString() will actually prepend the subdirectory, and it will cause test to fail. The only way to pass this line is to use the URL object.
If you like the idea of using variable on multiple places, then we can do something like this

$expected_destination = Url::fromRoute('entity.menu.edit_form', ['menu => $menu]);
$this->assertSession()->linkByHrefExists("admin/structure/menu/manage/$menu_name/add?destination=" . $expected_destination->toString());
$this->assertUrl($expected_destination);
botanic_spark’s picture

Here is a patch with fixes things mentioned in #32

phenaproxima’s picture

Status: Needs work » Reviewed & tested by the community

Interdiff looks right; RTBC once it passes tests. Thanks, @botanic_spark!

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs issue summary update, +Needs change record
  1. The issue summary needs an update with what the solution is. Also the title scared me as I thought this was going to add redirects to all local tasks.
  2. The idea looks really nice and this type of type helps to make a cohesive UI so a general +1
  3. +++ b/core/lib/Drupal/Core/Menu/LocalActionDefault.php
    @@ -119,7 +135,13 @@ public function getRouteParameters(RouteMatchInterface $route_match) {
    +    // Check if destination should be appended to the link.
    +    if (!empty($options['add_destination'])) {
    +      $options['query']['destination'] = $this->redirectDestination->get();
    +    }
    +    return $options;
    

    We need a change record to tell developers about the new option. We also should check core because there must some documentation somewhere about all the options in the menu_ui.links.action.yml files.

  4. +++ b/core/modules/menu_ui/src/Plugin/Menu/LocalAction/MenuLinkAdd.php
    @@ -2,6 +2,8 @@
    +@trigger_error('The ' . __NAMESPACE__ . '\MenuLinkAdd is deprecated in drupal:8.8.0. Instead, use `add_destination: true` option in declaration of action links.', E_USER_DEPRECATED);
    +
     use Drupal\Core\Menu\LocalActionDefault;
    

    Plugins aren't deprecated like this - we deprecate them in the constructor. This is because we only want to trigger on construction and not discovery.

  5. +++ b/core/modules/menu_ui/menu_ui.links.action.yml
    @@ -1,7 +1,8 @@
    +  options:
    +    add_destination: true
       appears_on:
         - entity.menu.edit_form
    

    I wonder about the name "add_destination" - I know that you mean to return to the route that the action appears on when the user presses a button that triggers a form submission but maybe not. Also maybe it would be even more useful if it was something like destination: entity.menu.edit_form so you could a completely different destination.

askibinski’s picture

Title: Local tasks should automatically have a default destination query string » Provide an optional destination parameter for local actions
Issue summary: View changes

Addressing #36:

1. Updated the issue summary with remaining tasks, also updated the title.
3. Found documentation in core in menu.api.php which seems relevant.
4. Needs work.
5. Needs discussion.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

lunk rat’s picture

Assigned: botanic_spark » Unassigned
Issue summary: View changes
Issue tags: -Needs issue summary update

Changing description. And +1 for @alexpott #36.5 idea to have this option take the form of: destination: some.route_name.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

claudiu.cristea’s picture

I've created a module for normal menu links and wanted to extend it also to tasks, actions, etc. https://www.drupal.org/project/menu_link_destination

I wonder if that could be extended to cover all types of links and a candidate to be ported in core.

However, I think, the core feature should cover all types of links (menu, actions, tasks, etc)

chrisolof’s picture

Attempt at a re-roll here against 9.3.x, with the deprecation code moved into the constructor per #36.4.

Re: #36.5 (custom destinations): I looked into this and realized it would add some complexity to my use case. To get back to the current page, I would need to supply not only a route name, but also a route parameter with the current node (eg. local action is displaying on node/123/bar). If we decide to try for destination customization, then we'll probably need to figure out how to handle both the route name and route parameters. I somewhat lean toward the simplicity of the current add_destination: true approach, keeping in mind that it's still possible to achieve a custom destination by adding a class.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

DieterHolvoet’s picture

Re-roll against 10.1.x, but also applies to 9.5.x.

sahil.goyal’s picture

Trying to fix CCF errors, Facing some difficulties to create interdiff, So here i updating the patch alone.

Nikhil_110’s picture

Trying to fix CCF errors and add interdiff..

Nikhil_110’s picture

Status: Needs work » Needs review
andypost’s picture

+++ b/core/lib/Drupal/Core/Menu/LocalActionDefault.php
@@ -37,11 +45,18 @@ class LocalActionDefault extends PluginBase implements LocalActionInterface, Con
+      @trigger_error('The redirect.destination service must be passed to LocalActionDefault::__construct(), it is required before Drupal 10.0.0.', E_USER_DEPRECATED);

+++ b/core/modules/menu_ui/src/Plugin/Menu/LocalAction/MenuLinkAdd.php
@@ -10,6 +10,10 @@
+ * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use the

@@ -35,6 +39,7 @@ class MenuLinkAdd extends LocalActionDefault {
+    @trigger_error("\Drupal\menu_ui\Plugin\Menu\LocalAction\MenuLinkAdd is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use the 'add_destination: true' option in declaration of action links.", E_USER_DEPRECATED);

deprecated in 10.1.0, removed from 11.0.0

mrinalini9’s picture

Status: Needs work » Needs review
FileSize
9.92 KB
2.26 KB

Updated patch #51 by addressing #53, please review it.

Thanks & Regards,
Mrinalini

larowlan’s picture

Reviewing for the 'Needs framework manager review' tag.

I would implement this differently

  • Firstly, copy MenuLinkAdd to Drupal\Core\Menu\LocalActionWithRedirect or similar
  • Secondly, gut MenuLinkAdd and have it extend the new class, and retain the deprecation error
  • Then instead of adding a new property to the yaml, for the links that need this, just add class: Drupal\Core\Menu\LocalActionWithRedirect

This avoids needing to add a new property and just uses the plugin system we already have.

Thoughts?

heddn’s picture

+1 to the idea in #55.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs issue summary update

Like the idea of #55 also.

Moving to NW for those changes. Also issue summary should be updated to match new proposal.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

gorkagr’s picture

Hi!

I like the idea of #55 as using a class called LocalActionWithRedirect is more intuitive than MenuLinkAdd.

On the other hand, in the documentation (a bit outdated), it is written in both menu.links and local.tasks examples of how to use the 'options' within the yml, and:

  options:
    query:
      destination: '/path/to/route'

can be defined if we need a destination different than the same route (which is added by default when using the class).

But nothing is documented in the links.actions page

Best

sime’s picture

Yes, per #59 if you do this code below then the current implementation of MenuLinkAdd will clobber this.

/**
 * Implements hook_menu_local_actions_alter(),
 */
function MYMODULE_menu_local_actions_alter(&$local_actions) {
  if (isset($local_actions['foo.bar'])) {
    $local_actions['foo.bar']['options']['query']['destination'] = '/cheese';
  }
}