Hello! I ran into an issue with @PublishEvent yesterday, not finding the correct tag with data-component-events attribute to look up the url.
My scenario: The component uses <t:container /> and has multiple direct descendants, meaning it will be rendered as it has multiple root nodes. Therefore, the PublishServerSideEvents mixin renders the data attribute on the first node. If an event is triggered with t5/core/ajax from an element in another component node, the lookup will fall back to <body> to start looking. But our <body> has a data-component-events attribute from the layout component. So the lookup fails. My proposal: Adding "boolean global() default false" to @PublishEvent, which will add the events to <body> if true, regardless of the components position in the DOM. The idea is that @PublishEvent events are component-bound events; that's why the lookup starts at the provided element, including recursively going upwards. If no element is provided, it looks at the body anyway. But right now, there's no option to put the url to the event there from Java. Possible risks: Duplicate event names on <body>. The mixin would need to verify this and throw an exception, or the global events are stored in another data-attribute like "data-global-component-events. In this case, the lookup logic must be adapted to look there first before falling back to <body>. Workaround/Alternatives: Either not using <t:container>, or putting all its descendant in another <div>, so the parent lookup succeds. Thoughts? I know it's an edge case, but I really like using <t:container> without further container-divs and many @PublishEvent throughout the project. If I find some time, I'm going to build a proof-of-concept over the weekend. Cheers Ben