Problem/Motivation

AFAIK this hasn't been reported anywhere but there is a bug in the Admin Toolbar and its criteria of showing the "Home" / "Back to site" button, for which this doesn't work anymore on admin themed pages that don't start with a /admin/ segment in the URL.

I am pretty convinced this has been regressed after the changes introduced in the first release of core 8.4.x and more specifically by the changes in #2542050: Toolbar implementation creates super annoying re-rendering..

Steps to reproduce:

  1. Install Drupal via 1 of the latest core versions 8.8.x is fine for this bug.
  2. Login as an admin and visit the front page or subsequently another page that doesn't have the admin theme to build the session storage with an item for escapeAdminPath.
  3. Go to an admin page and see that the first item in the toolbar shows either "Home" or "Back to site" if not the front page.
  4. Go to an admin page that doesn't start with a /admin/ segment eg. /taxonomy/term/xxx/edit or /user/xxx/edit which are still pages that use the admin theme. See how these pages do not show the "Home" or "Back to site" button.

When executing these exact same steps on core <8.4.x the above works correct.

Screenshots:

8.3.x Toolbar
8.4.x Toolbar

Origin:

The bug I believe originates from the added changes in core/themes/stable/css/toolbar/toolbar.module.css:

/**
 * Toolbar home button toggle.
 */
.toolbar .toolbar-bar .home-toolbar-tab {
  display: none;
}
.path-admin .toolbar-bar .home-toolbar-tab {
  display: block;
}

... where it was assumed that every admin themed page is identifiable with the .path-admin class. However as it turns out these are not interchangeable, because an admin themed page can perfectly fine not start with an "/admin/" segment for which that class is the actual representative, and we now end up having pages like the user edit or the taxonomy edit pages that don't have this button anymore.

Proposed resolution

Either extend the CSS classes that show the button or use a different class that is a more exact 1 on 1 representative of an admin themed page. At first I thought to extend it with another 2 selectors including .path-user and .path-taxonomy but that wouldn't be reliable or even be correct, as only the edit form of taxonomy pages are using the admin theme, and the same applies for the user entity pages.

Remaining tasks

Convert to MR
Respond to #41
Update proposed resolution

User interface changes

Add before and after screenshot here

API changes

None

Data model changes

None

Release notes snippet

None

Comments

baikho created an issue. See original summary.

baikho’s picture

Issue summary: View changes
baikho’s picture

Issue tags: +Usability
baikho’s picture

Assigned: baikho » Unassigned
Status: Active » Needs review
StatusFileSize
new2.41 KB

Here is an initial attempt for a fix, but well aware there may be better approaches to this.

Status: Needs review » Needs work
baikho’s picture

Right, this now breaks the layout builder tests because they are using a frontend theme and the changes in the patch do now check on is_admin_route.

shaktik’s picture

apply patch to solved back button issue.

baikho’s picture

Status: Needs work » Needs review
StatusFileSize
new2.41 KB
new840 bytes
pankaj.singh’s picture

Assigned: Unassigned » pankaj.singh
StatusFileSize
new63.52 KB
new62.95 KB

Tested and verified. Patch worked for me.

pankaj.singh’s picture

Assigned: pankaj.singh » Unassigned
pankaj.singh’s picture

Status: Needs review » Reviewed & tested by the community

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

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/toolbar/css/toolbar.module.css
--- a/core/themes/classy/templates/layout/html.html.twig
+++ b/core/themes/classy/templates/layout/html.html.twig

+++ b/core/themes/classy/templates/layout/html.html.twig
@@ -29,6 +30,7 @@
+    is_admin_route ? 'is-admin-route',

This is currently only added to Classy. Since this impacts the functionality of all themes, I think we should add this to system module and all core themes (including Stable)

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

johankleene’s picture

StatusFileSize
new4.88 KB

Slightly different solution, don't render the button when not in admin context, instead of trying to hide it through css. Could be there are some consequences that I don't see.

johankleene’s picture

Failed tests as button won't be rendered any more when not on admin pages. Adjusted tests.

jeroent’s picture

@JohanKleene, I believe the button is hidden in CSS because of caching purposes.

I created a new patch that is based on #8 and made the changes as suggested in #13.

jeroent’s picture

StatusFileSize
new12.46 KB
new808 bytes
jeroent’s picture

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

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.

erik seifert’s picture

aarti zikre’s picture

Assigned: Unassigned » aarti zikre

reviewing this and also confirm that this issue is found in D10 too..

aarti zikre’s picture

StatusFileSize
new47.06 KB

Verified #18 patch
Testing steps:

* created new instance of Drupal 9.5.x.
* Go to /admin/structure/taxonomy/manage/tags/overview.
* created one taxonomy.
* edit the taxonomy created in previous step.

After applying the patch still home or back to site is not visible.

Test result Fail.
Moving to need works.

Reference SS

After patch:
2022-08-08/3129705 after patch.png

aarti zikre’s picture

Status: Needs review » Needs work
aarti zikre’s picture

Assigned: aarti zikre » Unassigned
jeroent’s picture

Status: Needs work » Needs review
StatusFileSize
new13.51 KB
new810 bytes

Good catch @aarti zikre,

The patch attached should fix this behaviour for Claro.

Munavijayalakshmi’s picture

Assigned: Unassigned » Munavijayalakshmi
Munavijayalakshmi’s picture

Assigned: Munavijayalakshmi » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new63.83 KB
new63.75 KB

Patch #26 resolved issue.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 26: 3129705-26.patch, failed testing. View results

jeroent’s picture

Status: Needs work » Reviewed & tested by the community

Seems lika an unrelated test fail.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 26: 3129705-26.patch, failed testing. View results

jeroent’s picture

Status: Needs work » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 26: 3129705-26.patch, failed testing. View results

jeroent’s picture

Status: Needs work » Reviewed & tested by the community
alexpott’s picture

StatusFileSize
new8.38 KB

Here's a patch for 10.1.x and 10.0.x - some themes no longer exist :)

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs change record

I've discussed this issue with @lauriii and @ckrina and the consensus is that the fix is a good one.

However I've realised that we need a change record in order to tell themers with custom and contrib themes to update their html.html.twig to include this new class.

bramdriesen’s picture

Assigned: Unassigned » bramdriesen

Will create the change record.

bramdriesen’s picture

Assigned: bramdriesen » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs change record

Change record created, feel free to edit some of the wording as I found this one not particularly easy to write.

https://www.drupal.org/node/3313633

alexpott’s picture

I've rewritten the CR https://www.drupal.org/node/3313633 to more about what we want people to do rather than the bug itself.

bramdriesen’s picture

Status: Needs review » Reviewed & tested by the community

Yes, that looks a lot better! Thanks Alex.

alexpott’s picture

Status: Reviewed & tested by the community » Needs review

Hmmm... just wondering out load here but is the solution a bit complex and external to the toolbar module (where the problem lies).

I think we could change toolbar_preprocess_html() to

function toolbar_preprocess_html(&$variables) {
  if (!\Drupal::currentUser()->hasPermission('access toolbar')) {
    return;
  }
  $variables['attributes']['class'][] = 'toolbar-tray-open';
  $variables['attributes']['class'][] = 'toolbar-horizontal';
  $variables['attributes']['class'][] = 'toolbar-fixed';
  $variables['attributes']['class'][] = 'toolbar-loading';
  if (\Drupal::service('router.admin_context')->isAdminRoute()) {
    $variables['attributes']['class'][] = 'toolbar-is-admin-route';
  }
}

And then we could remove that changes to the templates and the other preprocess function, update the CSS for the new (more consistent class name) and not need a CR... wouldn't this be a better change?

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.

jeroent’s picture

Status: Needs review » Needs work
Issue tags: +Novice
nitin shrivastava’s picture

StatusFileSize
new8.97 KB
new607 bytes

@alexpott,
Made changes in toolbar_preprocess_html(), as per comment #41,
Please review.

bramdriesen’s picture

Thanks for the patch. Don’t forget to set the correct status on the issue 😉

nitin shrivastava’s picture

Status: Needs work » Needs review
jeroent’s picture

Status: Needs review » Needs work

Still needs some work:

And then we could remove that changes to the templates and the other preprocess function, update the CSS for the new (more consistent class name) and not need a CR... wouldn't this be a better change?

#41

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.

quietone’s picture

Issue summary: View changes
Issue tags: -Novice

Did a bit of triage here and this is no longer a novice level issue, mostly due to the work needed for #41.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

baikho’s picture

With Claro being replaced by Gin, I’m not sure this change is still necessary, as the issue does not occur in Gin.

quietone’s picture

Status: Needs work » Postponed

The Toolbar Module was approved for removal in #3476882: [Policy] Move Toolbar module to contrib.

This is Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.

The deprecation work is in #3484850: [meta] Tasks to deprecate Toolbar module and the removal work in #3488828: [meta] Tasks to remove Toolbar module.

quietone’s picture

Project: Drupal core » Toolbar
Version: main » 1.x-dev
Component: toolbar.module » Code
Status: Postponed » Needs work

Toolbar has moved to contrib