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: doneCheck 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:
After (new Home button on top-left corner):
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! |
Comment | File | Size | Author |
---|---|---|---|
#17 | interdiff-improved_backlink-2349569-5-17.txt | 1.03 KB | dmsmidt |
#17 | improved_backlink-2349569-17.patch | 905 bytes | dmsmidt |
Comments
Comment #1
valgibson CreditAttribution: valgibson commentedComment #2
screon CreditAttribution: screon commentedHi,
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.
Comment #3
marcvangendTagging because Yoroy asked me to :-)
Comment #4
screon CreditAttribution: screon commentedOk so my solution would be the following (or something alike):
Changing this:
To this:
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.
Comment #5
valgibson CreditAttribution: valgibson commentedYes 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?
Comment #6
screon CreditAttribution: screon commentedThanks for the feedback, your solution looks pretty good :)
Comment #7
marcvangendPatch applies as expected and IMO this is a usability improvement. Perhaps one of the Usablility people wants to have a look?
Comment #8
yoroy CreditAttribution: yoroy commentedI 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!
Comment #9
nod_sending new patch hang on.
Comment #10
valgibson CreditAttribution: valgibson commentedComment #11
2suns CreditAttribution: 2suns commentedPreparing screenshots before/after of first patch. (at Amsterdam2014)
Will do screenshots also of new patch, if required.
Comment #12
2suns CreditAttribution: 2suns commentedbefore, without Home button.
Comment #13
nod_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 :)
Comment #14
dmsmidtCreating simplified patch + check coding standards.
Comment #15
2suns CreditAttribution: 2suns commentedafter, with the new Home button.
Comment #16
2suns CreditAttribution: 2suns commentedComment #17
dmsmidtOk here you go: simplified and the else statement on the next line (according to coding standard)!
Comment #18
marcvangendComment #19
valgibson CreditAttribution: valgibson commentedComment #20
2suns CreditAttribution: 2suns commentedpatch #17, too, fixes the issue for me.
Comment #21
nod_yay! All good thanks!
Comment #23
marcvangendFailed testing because testbot encountered a too many connections error. Let's test again.
Comment #25
marcvangendBack to RTBC because it already was. Testbot will not run tests on JS changes anyway.
Comment #26
webchickThis 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
Comment #31
nod_don't know what's up with testbot.
Comment #32
dmsmidt