Hi there,
The destination query parameter is being stripped when the dropdown button is being rendered. This is a list of entities
PHP code used to add redirect parameters:
/**
* {@inheritdoc}
*/
protected function getDefaultOperations(EntityInterface $entity) {
$operations = parent::getDefaultOperations($entity);
/** @var RedirectDestination $redirectService */
$redirectService = \Drupal::service('redirect.destination');
$destination = $redirectService->getAsArray();
foreach ($operations as $key => $operation) {
$operations[$key]['query'] = $destination;
}
return $operations;
}
Markup in seven
<ul class="dropbutton"><li class="edit dropbutton-action"><a href="/temporal/1192/edit?destination=/node/4406/temporal/history" hreflang="en">Edit</a></li><li class="dropbutton-toggle"><button type="button"><span class="dropbutton-arrow"><span class="visually-hidden">List additional actions</span></span></button></li><li class="delete dropbutton-action secondary-action"><a href="/temporal/1192/delete?destination=/node/4406/temporal/history" hreflang="en">Delete</a></li></ul>
Markup in bootstrap (8.x-3.x-dev)
<button data-url="/temporal/1192/edit" class="btn-xs button js-form-submit form-submit btn-default btn icon-before" type="submit" name="op" value="Edit"><span class="icon glyphicon glyphicon-pencil" aria-hidden="true"></span>
Edit</button>
Note how the destination query param has disappeared.
I am unsure on what exactly is causing this, I was hoping that someone else could shed some light on this.
Comments
Comment #2
codexmas commentedI believe the issue is located in:
docroot/themes/bootstrap/src/Plugin/Preprocess/BootstrapDropdown.php:61
Line 61 ("$link = [") clearly overwrites by reference the original link structure wiping out the additional information like 'query'
I took a stab at various rendering methods to produce a url that would include the fully render link but my D8Fu is lacking today. Is it Friday yet?
Comment #3
codexmas commentedProblem solved after some additional debugging. The getDefaultOperations method that was used in the custom code was based off of the NodeListBuilder.php method as an example of how to do that in core.
The core node method applies the 'query' portion outside of the Url 'url object, and is rendered later on.
The more up to date and correct way to do this is to apply use the Url->setOption() method on the Url object itself instead:
This issue looks to be an artifact of the many many ways Url's can be generated and the current state of deprecation of render arrays of doom.
Comment #4
markhalliwellWhy have you set this issue to "fixed" when no patch has been provided, nor a duplicate issue linked (where the fix occurs)?
However, that being said, this sounds like a core issue so I'm moving it to the appropriate queue.
Comment #5
codexmas commentedMainly because the solution was in a custom module and not technically a Bootstrap issue as it turned out. Perhaps 'wont fix' or 'works as designed' are more appropriate.
This is essentially an issue of deprecations and implementation being ahead of core methods.
Notice that using bootstrap as a base theme the Operations on the admin/content and admin/people list builders don't have their destination query parameters as part of the url in the buttons?
Both of those list builders are setting the ['query'] in the $operation itself when it should really be the setOption('query', $destination) on the Url object.
I have been looking through the D8 queue to see if there is an existing issue but haven't found one specifically and am considering opening one.
Comment #6
star-szrThis sounds very similar to #2726471: active class doesn't get added to links LI when the URL has a query, possibly related?
Comment #8
willzyx commentedthis not seems a core issue and is reproducible only using bootstrap theme. With bartik, seven and other contrib theme the dropbuttons behavior is correct.
Links attributes and url options are not retained for dropbuttons probably because they are not taken in account in
BootstrapDropdown::preprocessLinks()?With this issue block_place module is unusable when bootstrap is the active theme
Comment #9
hctomOkay, so to get this working with the current theme/core versions, here is a patch that should solve the problem. I'd appreciate your reviews.
Comment #10
markhalliwellI think this should really use
NestedArray::mergeDeephere. Also, I think it would make more sense to assign the empty array to the variable above, not while doing the other operations below.Comment #11
hctomNo problem, here is the updated patch ;)
Comment #13
markhalliwell