- Issue created by @Anybody
- π¬π§United Kingdom catch
Closed π The AJAX messages command should render messages using the twig template Active as duplicate.
Bumping to major based on π 10.3 upgrade now missing status-message theme suggestions Needs work .
- πΊπΈUnited States Luke.Leber Pennsylvania
Injecting here that this would make styling file upload errors quite a bit easier!
It'd pay to take a hard look at the file module to determine how feasible the approach in the IS actually is.
- π¬π§United Kingdom catch
I took a look at how this could work.
The main thing we want, is to use #theme 'status_messages' to render the messages in PHP, before they're sent to JavaScript.
I think something like this would probably do it:
1. Add a new RenderedMessagesCommand - it would take an array of messages instead of a single one.
2. messages.js would need to support a new 'rendered' option (in the options array) where it just appends the markup string it was given, instead of passing it through Drupal.theme.message
3. RenderedMessagesCommand would take the messages array, pass it through '#theme' 'status_messages', add the 'rendered' option, and return otherwise the same structure as MessagesCommand.
4. To solve π 10.3 upgrade now missing status-message theme suggestions Needs work , we'd then use RenderedMessagesCommand in big pipe instead of MessageCommand.
It doesn't allow us to remove Drupal.theme.message though, because we provide a pure JavaScript API to add messages, and those can't be rendered in PHP, so the underlying issue that themes need to theme JavaScript messages separately is still there. That makes me wonder how useful it really is compared to opening issues against themes that don't implement message styling. e.g. I just found π Add js message theme override to match Umami message markup Needs review .
- πΊπΈUnited States Luke.Leber Pennsylvania
We've started to use drupalSettings + js_settings_alter to provide server-side rendered templates to the frontend.
Our Drupal.theme.messages implementation pulls the markup from drupalSettings. Might not be robust enough for core, but has worked rather well for us...and even covers the obscure file.module validation cruft too.
- πΉπ·Turkey Umit Turkey
These update problems of Drupal are so annoying that I'm at the point where I'm going to quit. There is no documentation on the subject. Why would they make such a change without consulting the community. I am not updating any site because of this issue.
- π¬π§United Kingdom catch
@luke.leber π 10.3 upgrade now missing status-message theme suggestions Needs work shows pretty conclusively that the current situation with separate js and twig theming isn't robust, so I think it's a good idea to try this - could you extract your logic into an MR? Seems OK for bc too given we'd be changing the default behaviour and js theme overrides should still work the same way.
- Status changed to Needs work
11 days ago 11:22am 2 September 2024 - πΊπΈUnited States Daniel Korte Brooklyn, NY
daniel korte β made their first commit to this issueβs fork.