Thanks for taking the time to read my question.
I have a problem adding the message and message status blocks in my content region using Drupal 9. I'm using a custom theme.
The blocks are simply not displayed. They are not even added to the DOM.
Here is my block configuration : https://i.sstatic.net/90fkY.jpg (Sorry, it's in French. The two blocks are underlined in red)
And the configuration of each block : https://i.sstatic.net/lq6jK.jpg and https://i.sstatic.net/eUScy.jpg (again, in French, but there are no restriction on page, role or type of content - it should appear everywhere)
I found these solutions online :
I tried uninstalling my theme, clearing the cache, reinstalling my theme but it doesn't work. The blocks did not appear in the Bartik theme either.
2 - https://www.drupal.org/forum/support/post-installation/2018-09-23/new-blocks-not-displaying
I tried adding a simple test block, it appears normally.
I tried displaying a test message using $this->messenger()->addMessage("test"); in a module to be sure there was something to display but with no success.
I'm not sure if it helps but here is my page.twig template :
<header aria-label="Site header" class="header" id="header" role="banner">
<div id='header-content'>
<div id="header-left">
{{ page.branding }}
{{ page.navigation }}
</div>
<div id='header-right'>
{{ page.user_menu }}
{{ page.search }}
</div>
</div>
</header>
<section class="main" id="main">
<main aria-label="Site main content" class="content" id="content" role="main">
{{ page.content }}
</main>
</section>
<footer aria-label="Site footer" class="footer" id="footer" role="contentinfo">
<div class="footer--top">
{{ page.footer_first }}
</div>
<div class="footer--bottom">
{{ page.footer_bottom }}
</div>
</footer>
Does any of you already encountered the problem ? Is there a solution ?
Thanks again !
EDIT
Here is the output from twig debug :
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'block' -->
<!-- FILE NAME SUGGESTIONS:
* block--messages.html.twig
x block--system-messages-block.html.twig
* block--system.html.twig
* block.html.twig
-->
<!-- BEGIN OUTPUT from 'core/modules/system/templates/block--system-messages-block.html.twig' -->
<div data-drupal-messages-fallback class="hidden"></div><span data-big-pipe-placeholder-id="callback=Drupal%5CCore%5CRender%5CElement%5CStatusMessages%3A%3ArenderMessages&args%5B0%5D&token=_HAdUpwWmet0TOTe2PSiJuMntExoshbm1kh2wQzzzAA"></span>
<!-- END OUTPUT from 'core/modules/system/templates/block--system-messages-block.html.twig' -->
This suggests that the \Drupal::messenger()->addMessage(); does not output any message.
A strange thing I noticed testing with a FormBase class is that the Drupal\Core\Form\FormStateInterface::setErrorByName() method is working fine. A message is being displayed and the twig debug output becomes
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'block' -->
<!-- FILE NAME SUGGESTIONS:
* block--cessoc-messages.html.twig
x block--system-messages-block.html.twig
* block--system.html.twig
* block.html.twig
-->
<!-- BEGIN OUTPUT from 'core/modules/system/templates/block--system-messages-block.html.twig' -->
<div data-drupal-messages-fallback class="hidden"></div>
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'status_messages' -->
<!-- BEGIN OUTPUT from 'core/modules/system/templates/status-messages.html.twig' -->
<div data-drupal-messages>
<div role="contentinfo" aria-label="Message d'erreur">
<div role="alert">
<h2 class="visually-hidden">Message d'erreur</h2>
The title must be at least 5 characters long.
</div>
</div>
</div>
<!-- END OUTPUT from 'core/modules/system/templates/status-messages.html.twig' -->
<!-- END OUTPUT from 'core/modules/system/templates/block--system-messages-block.html.twig' -->
My problem is solved !
Like Kien Nguyen suggested, this was an issue caused by the BigPipe module not filling the message block with the status messages.
Apparently, this was because my theme contained a jQuery.js file which was outdated. I deleted it and everything work fine now.