Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295735

JavaScript Messages API cannot remove message from backend

$
0
0

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

  1. 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) .
  2. Note that there is no "data-drupal-message-id" attributes on the status message element.
  3. 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 using Drupal.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.


Viewing all articles
Browse latest Browse all 295735


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>