Problem/Motivation
The user menu link of the toolbar is not working properly with the BigPipe module. I installed Drupal 8.5.0 with the standard profile and when I click the user menu link of the toolbar the page refreshes instead of opening the toolbar menu tray. When BigPipe is not installed everything is working fine.
When BigPipe is enabled, the toolbar username/My account tab title is rendered via #lazy_builder => ['user.toolbar_link_builder:renderDisplayName', []],
(line 1373 of user.module) which, once rendered, wraps the username in a div tag. This new child element of the anchor tag prevents the toolbar menu tray from opening when directly clicked on. Clicking around the username text works since that bypasses the div element.
Proposed resolution
The JavaScript to trigger the menu tray opening uses event.target (which is the div tag when clicking on the username text) instead of event.currentTarget (the anchor tag). Changing the target fixes the issue and the tab behaves like all other toolbar tabs with menu trays whether children exist or not.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#18 | 2952626-18.patch | 1.52 KB | tstoeckler |
#2 | drupal850bigpipe.gif | 284.56 KB | romainj |
Comments
Comment #2
romainj CreditAttribution: romainj as a volunteer commentedComment #3
cilefen CreditAttribution: cilefen at Institute for Advanced Study commentedComment #4
Wim LeersThanks for reporting! I will look into this.
Comment #5
Daniel KorteI missed this issue because it's an issue with the toolbar module rather than BigPipe, but they are related. Thanks @cilefen
I created a patch for this issue here: https://www.drupal.org/project/drupal/issues/2957975
Comment #6
cilefen CreditAttribution: cilefen at Institute for Advanced Study commentedI duplicated the other issue and based on its patch, this is toolbar module.
Comment #7
Daniel KorteComment #8
cilefen CreditAttribution: cilefen at Institute for Advanced Study commentedComment #9
slasher13Applied patch and it works!
Comment #10
lauriiiComment #11
Wim LeersAhhhh, that makes much more sense! I'm glad it wasn't a BigPipe bug after all :)
Comment #12
romainj CreditAttribution: romainj as a volunteer commentedMany thanks to all of you.
Comment #13
alexpottYeah I noticed that this was broken. Do we know what broke it? Also given that this is something we can break we should have a JavascriptTestBase test for it. Probably can add something to ToolbarIntegrationTest.
In order to commit a bug fix we need an automated to test to prove that we've fixed the bug and ensure that we don't break it again in the future. For more information about writing tests in Drupal 8 see the following links:
Comment #14
alexpottComment #15
John Pitcairn CreditAttribution: John Pitcairn commentedGonna need a re-roll for 8.6 I think.Hmm ... I can't reproduce the problem in 8.6.0-rc1. Looks like #736066: ajax.js insert command sometimes wraps content in a div, potentially producing invalid HTML and other bugs might have fixed it?
Comment #16
John Pitcairn CreditAttribution: John Pitcairn commentedComment #17
Daniel KorteI haven’t been able to test in 8.6.0-rc1, but either way the current implementation of
event.target
is incorrect. This needs to useevent.currentTarget
since the actions should be performed on the anchor tag and not any child of it, such as a SVG icon or a div.target
is the element that triggered the event (e.g., the user clicked on)currentTarget
is the element that the event listener is attached to.via Stack Overflow
Comment #18
tstoecklerHere's a re-roll.
Comment #19
BerdirAs #15 said, maybe the change still makes sense, but I'd actually expect that the div is no longer there now per the issue referenced in #15.
Comment #20
Daniel KorteThe div is not there, but that is no reason to leave shaky code in place IMHO.
Comment #21
lauriiiI tried to rewrite the title since the actual user-facing bug has been fixed. It probably still makes sense to make this change there shouldn't be any downsides in making it.
Comment #22
lauriiiThis probably should be moved back to needs review status since I removed the needs tests tag in the previous comment.
Comment #23
lauriiiThe change looks good for me so I'm moving this to RTBC.
Comment #24
GrandmaGlassesRopeMan👍 from me!
Comment #25
alexpottCommitted d2989e4 and pushed to 8.7.x. Thanks!
Crediting @John Pitcairn for finding out that the bug has been fixed and referencing the issue that fixed it.