πΊπΈUnited States mattc321
I extend my own MessageCommand to make this easier to reuse, but here is a direct simplified work around, returning a proper status message. Of course, many ways to do this while we await the fix in 3396318 π AJAX MessageCommand markup and styling differs from Theme default Needs work
public function myControllerResponseOrAjaxCallback() {
$build = [
'#theme' => 'status_messages',
'#message_list' => [
'error' => [
'#markup' => t('An error occurred!'),
]
],
'#status_headings' => [
'status' => t('Status message'),
'error' => t('Error message'),
'warning' => t('Warning message'),
],
];
$output = \Drupal::service('renderer')->render($build);
$response = new AjaxResponse();
$response->addCommand(new MessageCommand($output));
return $response;
}