Problem/Motivation
When you login, the toolbar-icon appears at the top right corner of the screen. When you reload the page however, this toolbar-icon has now disappeared. I added screenshots to demonstrate this bug.
On the first login, the toolbar-icon appears at the top right corner. This is the result we would expect.

Source:

When reloading the page, this toolbar icon has now disappeared. We would expect the toolbar-icon to be visible on the exact same location.

Source:

Proposed resolution
TBD.
Remaining tasks
TBD.
User interface changes
Show the icon on a page reload.
API changes
None.
Comments
Comment #1
wim leersThis is a very subtle regression introduced by #2136507: Use client-side cache tags & caching to eliminate 1 HTTP requests/page for rendering Contextual Links (which landed just a few days ago). Thank you for reporting it! :)
I've already done a first round of debugging. It's definitely caused by #2136507, because it works fine on the first page load (i.e. cold client-side cache), but is consistently broken on subsequent page loads (i.e. warm client-side cache).
The fun part: even when stepping through it with a debugger, everything works correctly! For some reason, the "collection add" event is not triggered, or at least
contextual.toolbar.js' callback is not triggered.Comment #2
wim leersComment #3
wim leersComment #4
sqndr commentedThis patch seems to fix the described issue. I can reload the page and the pencil always appears at the top right corner.
I think it's best if someone with more experience about #2136507 or the contextual module reviews the technical part of the patch.
Comment #5
wim leersThanks for the review, sqndr! :) I agree, a JS person should also review the patch.
Comment #7
wim leers3: contextual_toolbar_toggle_client_side_cache-2181527-3.patch queued for re-testing.
Comment #8
nod_This is a reroll because the indentation standard changed for JavaScript files. No need for commit credit because of this reroll.
Comment #9
wim leers8: core-js-contextual-toolbar-client-cache-2181527-8.patch queued for re-testing.
Comment #10
jessebeach commentedSo the fix is to move the searching of the DOM into the next evaluation cycle with
window.setTimeoutto give a chance for inserted nodes to write into the DOM before we go searching for them.Testing and verified that this patch restores the Edit pencil.
Comment #11
nod_I know, I know. Opened #2212283: Auto-format JS files.
Comment #12
webchickOh, rad! I've totally had this happen to me before, but had absolutely no idea why, and thought I was going crazy. Well, I am going crazy. ;) But at least not because of this bug. :D
Committed and pushed to 8.x. Thanks!
Comment #13
wim leersHaha Angie :)