Issue #3307519 by Darren Oh: Fix workspace link not redirecting to current page
Link was redirecting to the page where the toolbar was first generated.
Closes #3307519
Merge request reports
Activity
273 'title' => t('Switch workspace'), 274 'class' => ['use-ajax', 'toolbar-icon', 'toolbar-icon-workspace'], 275 'data-dialog-type' => 'dialog', 276 'data-dialog-renderer' => 'off_canvas_top', 277 'data-dialog-options' => Json::encode([ 278 'height' => 161, 279 'classes' => [ 280 'ui-dialog' => 'workspaces-dialog', 281 ], 282 ]), 267 '#lazy_builder' => [ 268 'workspaces.lazy_builders:renderToolbarTab', 269 [], 283 270 ], 284 '#cache' => ['tags' => $active_workspace ? $active_workspace->getCacheTags() : []], 271 '#create_placeholder' => TRUE, Should this have a placeholder preview that's also a link to avoid any layout shift issues? (see https://www.drupal.org/node/3338948)
46 'use-ajax', 47 ], 48 'data-dialog-type' => 'dialog', 49 'data-dialog-renderer' => 'off_canvas_top', 50 'data-dialog-options' => Json::encode([ 51 'height' => 161, 52 'classes' => [ 53 'ui-dialog' => 'workspaces-dialog', 54 ], 55 ]), 56 ], 57 '#attached' => [ 58 'library' => ['workspaces/drupal.workspaces.toolbar'], 59 ], 60 '#cache' => [ 61 'contexts' => ['url.path'], RedirectDestination::get() uses query parameters as well as the route, I think this might need to be more specific (route + route params + url.query?)
Also wondering whether this one is worth caching, I guess it's a current route lookup and not per-user so probably still is just about, it's not like every site visitor is using the toolbar or workspaces so the number of cache entries won't be that high.
Edited by catchchanged this line in version 3 of the diff
Now that you mention it, I think it's not worth caching at all. Especially since https://www.drupal.org/project/drupal/issues/2983105 wants to make the list of recent workspaces per-user.
Disabled caching for the lazy-built element, and added test coverage that we're not disabling dynamic page cache completely.
added 1 commit
- 799ec44d - Disable caching for the toolbar workspace switcher.