Verified Commit 03f71c73 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

(cherry picked from commit bff71e54)
parent b55abf3d
Loading
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -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;
+0 −13
Original line number Diff line number Diff line
@@ -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',