Problem/Motivation

If a user is on an admin page and the 'escapeAdminPath' sessionStorage is null, the data-toolbar-escape-admin button will flicker and cause a reflow due to its default text of "Back to site" changing to the different-width "Home" after Drupal.behaviors.escapeAdmin completes.

Steps to reproduce

Open an admin page in a new tab or on an existing admin page, delete the 'escapeAdminPath' sessionStorage item and refresh.

Proposed resolution

Remove the logic that changes the link text so it always says "Back to site", which is accurate link text whether it links to the non-admin home page or the last visited non-admin page. This eliminates the text change that causes the reflow.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3357112

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bnjmnm created an issue. See original summary.

bnjmnm’s picture

Status: Active » Needs review
StatusFileSize
new317.52 KB

MR with a solution is up. This sets a minimum width on the button that keeps track of the button's maximum possible width and sets it to that so there's room for the new content to be added without reflowing.

The button contents now fade in as well, so the JS updating of the text ideally isn't visible, but on slower systems it will still be less apparent.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Confirmed the "flicker" when I deleted escapeAdminPath in chrome.
MR does solve that.

Not sure about the fade in feature but won't hold the ticket up on a detail like that.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work

I'm not sure I understand why we need the fading here. It is quite notable, potentially even more so than the current reflow. I tried removing the fading from the patch and it seems that that improves the situation without any negative side effects. Moving to needs work to either remove the fade or to document why it's needed.

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new1.56 MB

I'm not sure I understand why we need the fading here

I didn't like the name switching like that and figured I'd give it a shot at least,

But it's not super important to me and I removed it. A better version would keep the icon in place, too.

I also figured it was something a reviewer might notice if they were paying specific attention to that toolbar tab. However, that text switching is pre-existing AND this issue is specific to addressing the reflow so it's not like it has to happen here even if it was something there was interest in.

bnjmnm’s picture

Note the gifs in #6 and #3 are playing slower than what I recorded. Anybody basing a decision that is impacted by that slowness should probably evaluate locally.

smustgrave’s picture

Status: Needs review » Needs work

Seems removing add some failures in the tests.

bnjmnm’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Tested following the same steps in #4.

Don't see the flicker with "back to site" link but do see it with my username. Think that's out of scope but wanted to point out if it matters or not.

lauriii’s picture

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

hooroomoo made their first commit to this issue’s fork.

hooroomoo’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll

Rerolled and confirmed that width of the admin escape doesn't change after deleting the 'escapeAdminPath' sessionStorage item and refreshing.

lauriii’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new40.46 KB
new39.71 KB

Just realized that this change actually leads into before/after changes. When I tested this last time on #5, I didn't realize that the session storage wouldn't be set on the initial page load, and didn't realize there was this change.

Before:

After:

I'm wondering if people actually expect to see the "Home" link, rather than "Back to site". IMO back to site isn't wrong, even if it links to the front page of the site. Maybe we could address this by changing the link text always to "Back to site". Thoughts?

bnjmnm’s picture

I'm wondering if people actually expect to see the "Home" link, rather than "Back to site". IMO back to site isn't wrong, even if it links to the front page of the site. Maybe we could address this by changing the link text always to "Back to site". Thoughts?

It definitely crossed my mind that this whole thing would be solved by not changing the link wording at all. I'm skeptical that the distinction between "Home" and "Back to Site" provides much benefit or is even noticed. My biggest reason for the current approach is that it's the way to fix the reflow with the fewest overall changes, and extra-width "home" will appear far less frequently than same-width "back to site"

The change was made 9 yrs ago in #2349569: 'Back to site' link does not work as expected. I wonder if the problem had more to do with the link not consistently being there, vs the wording used. I wouldn't mind just removing that conditional text entirely if there were some +1-ing of that.

lauriii’s picture

Thank you for linking the original issue where this was introduced @bnjmnm! Based on that, there wasn't any strong reason to use a separate text for the home link, and we would not be re-introducing that bug if we changed the text.

bnjmnm’s picture

This is the solution I prefer anyway, glad there's support for it. I opened a do-not-switch-to-saying-home MR that eliminates the reflow by not changing that button's text.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Hate to be that guy but since the solution changed can we update the issue summary with the proposed solution please.

bnjmnm’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update

No prob, issue summary updated.

hooroomoo’s picture

Status: Needs review » Reviewed & tested by the community

Works like a charm

ckrina’s picture

Late to the party, but 100% agree with the late change to always use the same "Back to site" text.

  • lauriii committed ca3d4fe5 on 10.1.x
    Issue #3357112 by bnjmnm, hooroomoo, lauriii, smustgrave, ckrina: Reduce...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Committed ca3d4fe and pushed to 10.1.x. Thanks!

Status: Fixed » Closed (fixed)

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