setActiveThread is not called when loading the page private-messages

Created on 12 November 2024, 9 days ago

Problem/Motivation

A common usage of Private Message is to display the Inbox block in a sidebar and the selected thread in the main content.

In these conditions, when the main page "/private-messages" is open, the first thread in the Inbox will be displayed in the main content. Thus, the first thread in the Inbox should be highlighted and for that it should have the class "active-thread". But this is not happening.

Steps to reproduce

Display the Inbox block in a sidebar and the selected thread in the main content.
Go to "/private-messages".
Check that the first thread in the Inbox is not highlighted. Also inspect the code and check that the class "active-thread" is missing in the element's <div>.

The problem is that the library "private_message_thread_script" depends on the library "inbox_block_script" for this to work correctly.
This can be seen here: https://git.drupalcode.org/project/private_message/-/blob/3.0.2/js/priva...
If Drupal.PrivateMessages.setActiveThread defined in "inbox_block_script" does not exist, Drupal.PrivateMessages.setActiveThread(originalThreadId); is not running.

This dependency is not declared in the file "private_message.library.yml" and like that the order that the libraries are loaded is not always correct.

Proposed resolution

I don't think we can set the dependency in the libraries file, since we may not want to always show the Inbox.

My proposal is to change the code so that the library "inbox_block_script"" depends on the library "private_message_thread_script".
And declare that dependency in the file "private_message.library.yml" to be sure that the files are loaded in the right order.

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡΅πŸ‡ΉPortugal dxvargas

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024