Problem

When I'm on a homepage of a Drupal 8 site and I surf to an admin page I get a 'Back to site' link in the upperleft corner of the screen, as expected. This takes me to the last entered page.
But when I open a new browsertab and I surf directly towards e.g. http://mysitename/admin/content the 'Back to site' link doesn't show up. It will never show up as long as I stay in the admin section. Instead I have to manually change the url to get back to the frontend of the site.
In the 'escapeAdmin.js' file of the toolbar module it says in the comments: 'Replaces the home link in toolbar with a back to site link.' So, technically speaking this is true: it replaces the homelink with a back to site link. But if there IS no homelink (because I went directly to the admin section) it doesn't replace anything. This doesn't feel right. I often tell clients where they should directly go in the admin section to edit something or configure something. It would be nice then, to be able to navigate to your homepage after your actions, instead of changing your url to the desired one.

Proposed solution

I think the best solution would be to do a partly rewrite of the functionality of the history link. The homelink already exists but is hidden. At this time it is only being revealed whenever there's a 'last entered page' link available AND we're in admin section. We'll add another else-if statement to find out if we're in admin section. Then if the 'last entered page' link isn't available we'll reveal the 'Back to site' link and change the caption to 'Home', because this makes everything clear.

Remaining tasks

  • Create screenshots from before and after: done
  • Check coding standards javascript on if / else statement: done

User interface changes

A 'Back to site' link will always be visible (except on the homepage), as long as you're logged in to a Drupal Site.

Before:
before
After (new Home button on top-left corner):
after

 

Contributor tasks needed
Task Novice task? Contributor instructions Complete?
Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards Instructions Done!
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

valgibson’s picture

Issue summary: View changes
screon’s picture

Assigned: Unassigned » screon

Hi,

Your proposed solution sounds good. It certainly is a good idea to always show the back to site link as you say, because clients do rely on that link to get out of the admin interface.

I'll take a look at it, I'm also at DrupalCon.

marcvangend’s picture

Issue tags: +Needs usability review

Tagging because Yoroy asked me to :-)

screon’s picture

Assigned: screon » Unassigned

Ok so my solution would be the following (or something alike):

Changing this:

Drupal.behaviors.escapeAdmin = {
    attach: function () {
        console.log(escapeAdminPath);
      var $toolbarEscape = $('[data-toolbar-escape-admin]').once('escapeAdmin');
      if ($toolbarEscape.length) {
        if (pathInfo.currentPathIsAdmin && escapeAdminPath !== null) {
          $toolbarEscape.attr('href', escapeAdminPath);
          $toolbarEscape.closest('.toolbar-tab').removeClass('hidden');
        }
      }
    }
  };

To this:

Drupal.behaviors.escapeAdmin = {
    attach: function () {
        console.log(escapeAdminPath);
      var $toolbarEscape = $('[data-toolbar-escape-admin]').once('escapeAdmin');
      if ($toolbarEscape.length) {
        if (pathInfo.currentPathIsAdmin && escapeAdminPath !== null) {
          $toolbarEscape.attr('href', escapeAdminPath);
          $toolbarEscape.closest('.toolbar-tab').removeClass('hidden');
        } else if (pathInfo.currentPathIsAdmin && escapeAdminPath === null) {
            $toolbarEscape.attr('href', '/');
            $toolbarEscape.text(Drupal.t('Go to homepage'));
            $toolbarEscape.closest('.toolbar-tab').removeClass('hidden');
        }
      }
    }
  };

In other words: when there is no admin path from the session, set the link to direct to the site's homepage and change the displayed linktext for usability. Because if you haven't been on the homepage a text saying "Go back to site" could be confusing. So I think something like "Go to homepage" would be more evident. I doubt that changing the title here is the way to go, but that is the first thing I thought of.

Anyways, my change always makes sure there is a link that redirects the user to the front end.

valgibson’s picture

Status: Active » Needs review
FileSize
662 bytes

Yes indeed, 'Back to site' could be confusing, but maybe 'Go to homepage' is a little to long? I think just 'Home' in this case would be clear. Also this line $toolbarEscape.attr('href', '/'); in the second if-comparison, is not needed, as it already defaults to the homepage. I created a patch to implement this. Could it be reviewed?

screon’s picture

Thanks for the feedback, your solution looks pretty good :)

marcvangend’s picture

Status: Needs review » Reviewed & tested by the community

Patch applies as expected and IMO this is a usability improvement. Perhaps one of the Usablility people wants to have a look?

yoroy’s picture

I think this is an elegant solution. I looked this over with marc and saw that without this fix there is only the 'Home' link in the breadcrumb that will allow you to navigate to the frontend of your site. So we need to do something and this seems the right approach. Bojhan had a look and was ok as well :) Go for it!

nod_’s picture

Status: Reviewed & tested by the community » Needs work

sending new patch hang on.

valgibson’s picture

Issue summary: View changes
Issue tags: -Needs usability review
2suns’s picture

Preparing screenshots before/after of first patch. (at Amsterdam2014)
Will do screenshots also of new patch, if required.

2suns’s picture

FileSize
28.6 KB

before, without Home button.

nod_’s picture

Just asked in person to simplify the logic instead of having code duplication. Bouncing back to @valgibson and @marcvangend to change the patch so we can RTBC :)

dmsmidt’s picture

Creating simplified patch + check coding standards.

2suns’s picture

FileSize
35.01 KB

after, with the new Home button.

2suns’s picture

Issue summary: View changes
dmsmidt’s picture

Ok here you go: simplified and the else statement on the next line (according to coding standard)!

marcvangend’s picture

Status: Needs work » Needs review
valgibson’s picture

Issue summary: View changes
2suns’s picture

patch #17, too, fixes the issue for me.

nod_’s picture

Status: Needs review » Reviewed & tested by the community

yay! All good thanks!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 17: improved_backlink-2349569-17.patch, failed testing.

marcvangend’s picture

Status: Needs work » Needs review

Failed testing because testbot encountered a too many connections error. Let's test again.

marcvangend’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC because it already was. Testbot will not run tests on JS changes anyway.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

This is AWESOME!! I can't tell you how many times I've been bitten by this. Thank you so much!

Tried it every which way and it works as expected.

Committed and pushed to 8.0.x. Thanks! :D

  • webchick committed 383521f on 8.0.x
    Issue #2349569 by dmsmidt, valgibson, nod_, 2suns, yoroy, Bojhan,...

Status: Fixed » Needs work

The last submitted patch, 17: improved_backlink-2349569-17.patch, failed testing.

The last submitted patch, 17: improved_backlink-2349569-17.patch, failed testing.

nod_’s picture

Status: Needs work » Fixed

don't know what's up with testbot.

dmsmidt’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.