reverted: --- b/core/lib/Drupal/Core/Render/Element/StatusMessages.php +++ a/core/lib/Drupal/Core/Render/Element/StatusMessages.php @@ -73,18 +73,21 @@ * @see drupal_get_messages() */ public static function renderMessages($type) { + $render = []; $messages = drupal_get_messages($type); + if ($messages) { + // Render the messages. + $render = [ + '#theme' => 'status_messages', + // @todo Improve when https://www.drupal.org/node/2278383 lands. + '#message_list' => $messages, + '#status_headings' => [ + 'status' => t('Status message'), + 'error' => t('Error message'), + 'warning' => t('Warning message'), + ], + ]; + } - // Render the messages. - $render = [ - '#theme' => 'status_messages', - // @todo Improve when https://www.drupal.org/node/2278383 lands. - '#message_list' => $messages, - '#status_headings' => [ - 'status' => t('Status message'), - 'error' => t('Error message'), - 'warning' => t('Warning message'), - ], - ]; return $render; } diff -u b/core/misc/message.js b/core/misc/message.js --- b/core/misc/message.js +++ b/core/misc/message.js @@ -156,14 +156,13 @@ if (!options.priority && (type === 'warning' || type === 'error')) { options.priority = 'assertive'; } - // Always announce the type of the upcomming message. - Drupal.announce(type, options.priority); // If screen reader message is not disabled announce screen reader specific // text or fallback to the displayed message. - if (options.announce !== '') { - Drupal.announce(options.announce || message, options.priority); - } + Drupal.announce((typeof options.announce === 'string' && options.announce !== '') ? + options.announce : + message, options.priority); + } /**