Skip to content
Snippets Groups Projects

Issue #3495223: Improve UX for Local Tasks in Toolbar

1 file
+ 12
2
Compare changes
  • Side-by-side
  • Inline
@@ -102,6 +102,16 @@ class AdminToolbarToolsHelper {
@@ -102,6 +102,16 @@ class AdminToolbarToolsHelper {
}
}
}
}
 
$local_tasks_default_url = Url::fromRoute('<none>');
 
$local_tasks_default_title = $this->t('Local Tasks');
 
// Set default URL to entity edit form if available.
 
foreach ($local_task_links['#links'] as $route_name => $link) {
 
if (preg_match('/^entity\..+\.edit_form$/', $route_name)) {
 
$local_tasks_default_url = $link['url'];
 
$local_tasks_default_title = $link['title'];
 
}
 
}
 
$build = [
$build = [
'#type' => 'toolbar_item',
'#type' => 'toolbar_item',
'#wrapper_attributes' => [
'#wrapper_attributes' => [
@@ -117,8 +127,8 @@ class AdminToolbarToolsHelper {
@@ -117,8 +127,8 @@ class AdminToolbarToolsHelper {
// This means that for now we always render Local Tasks item even
// This means that for now we always render Local Tasks item even
// when the tray is empty.
// when the tray is empty.
'#type' => 'link',
'#type' => 'link',
'#title' => $this->t('Local Tasks'),
'#title' => $local_tasks_default_title,
'#url' => Url::fromRoute('<none>'),
'#url' => $local_tasks_default_url,
'#attributes' => [
'#attributes' => [
'class' => [
'class' => [
'toolbar-icon',
'toolbar-icon',
Loading