Javascript files loaded twice when clicking on thread link in PM block

Created on 11 May 2019, over 5 years ago
Updated 8 October 2024, 2 months ago

Hello,

I need some help identifying a strange issue with private message module. I don't really know yet, what is causing this bug. It could be caused by Private Message Module or Bootstrap Theme or Drupal itself. The following behavior is happening with the 8.x.-2.x versions and also 8.x.-1.x versions.
I setup the private message block to select the conversation/thread on the left region area. I noticed when I use this block provided by PR module under the path ../private_messages the chat is loaded without page refresh (via ajax). That’s really cool but:
It is changing to many parts from the DOM I think. It is appending all javascript files AGAIN what is causing setting jquery events a second time.
For example: When I then click the bootstrap navbar-toogle it is expanding and immediately collapsing the menu again. Because the event is asigned double. So it's not possible to open the menu anymore.
When I now change the current chat by selecting another thread in the private messages block. Then it is loading the chat like expected but also again (3rd time now) the javascript files (again appended at the end within body). So it is setting again all onclick events to the objects. After 3rd time the menu is working because all click events running 3 times now (1st toggle: expanding, 2nd: hiding, 3rd: expanding). The next click on another thread in the PR block would start the procedure again and again…

At the attached picture you can see what the private message block is requesting from the Server when I click on a thread.

It is requesting "load_thread" with a token and the id of the conversation. In the response I can see a very long json object.

I can see there is also a command in this json value what is including the following:
{"command":"insert","method":"append","selector":"body","data":"\u003Cscript src=\u0022\/core\/assets\/vendor\/domready\/ready.min.js?v=1.0.8 ... and so on...
It looks like this is telling drupal to append the js files again at the end of the DOM (before the body ends). How can I fix that behavior?

πŸ’¬ Support request
Status

Needs work

Version

3.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany gomurr

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024