Skip to content
Snippets Groups Projects
Verified Commit 74d72efa authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3396099 by Utkarsh_33, nod_, Gauravvvv, bnjmnm, tedbow, smustgrave,...

Issue #3396099 by Utkarsh_33, nod_, Gauravvvv, bnjmnm, tedbow, smustgrave, Anybody, Rob230: The core/drupal.message library requires a status_messages render element
parent 3e3b4953
No related branches found
No related tags found
No related merge requests found
......@@ -37,13 +37,27 @@
* The default destination for JavaScript messages.
*/
static defaultWrapper() {
let wrapper = document.querySelector('[data-drupal-messages]');
// Search for the element with '[data-drupal-messages]' selector.
// If not found then only try to search for fallback element.
let wrapper =
document.querySelector('[data-drupal-messages]') ||
document.querySelector('[data-drupal-messages-fallback]');
if (!wrapper) {
wrapper = document.querySelector('[data-drupal-messages-fallback]');
// If no status messages element is found, a fallback element is created to prevent
// execution-breaking JS errors when attempting to report a problem.
// This scenario can occur on any page that does not include a status_messages
// render element.
wrapper = document.createElement('div');
document.body.appendChild(wrapper);
}
if (wrapper.hasAttribute('data-drupal-messages-fallback')) {
// Remove the fallback attribute if it exists.
wrapper.removeAttribute('data-drupal-messages-fallback');
wrapper.setAttribute('data-drupal-messages', '');
wrapper.classList.remove('hidden');
}
wrapper.setAttribute('data-drupal-messages', '');
return wrapper.innerHTML === ''
? Drupal.Message.messageInternalWrapper(wrapper)
: wrapper.firstElementChild;
......
......@@ -58,19 +58,6 @@ public function batchPage(Request $request) {
return $output;
}
elseif (isset($output)) {
// Directly render a status message placeholder without any messages.
// Messages are not intended to be show on the batch page, but in the
// event an error in a AJAX callback the messages will be displayed.
// @todo Remove in https://drupal.org/i/3396099.
$output['batch_messages'] = [
'#theme' => 'status_messages',
'#message_list' => [],
'#status_headings' => [
'status' => $this->t('Status message'),
'error' => $this->t('Error message'),
'warning' => $this->t('Warning message'),
],
];
$title = $output['#title'] ?? NULL;
$page = [
'#type' => 'page',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment