Problem/Motivation
`Drupal.Message.remove()` & `Drupal.Message.clear()` cannot remove messages from backend since all backend messages missing the `[data-drupal-message-id]` attribute.
Steps to reproduce
- Trigger or create a status message displayed either in the frontend or admin theme (assuming status-messages.html.twig is still using the template from core) .
- Note that there is no "data-drupal-message-id" attributes on the status message element.
-
Open the javascript console and run:
new Drupal.Message().add('Test message');
. The newly created status message has the data-drupal-message-id attribute and so can be removed usingDrupal.Message().remove(id)
Side note: Status messages created in Javascript seem to be inserted inside of status messages from the backend.
Proposed resolution
Determine whether the it's the intention of the Javascript Message API to interact with status messages from the backend as it works at the moment or if it's just supposed to interact with status messages it creates.
Update the status-messages.html.twig file to have a "data-drupal-message-id" attribute added, we may also need a better unique ID if some variation of "title_ids[type]" variable isn't unique enough.
It's also worth noting that if that ID is added to the main wrapper in the status-messages template file, if there are multiple messages, they would all share the same ID added to the wrapper.