The discussion revolves around accessing the toolbarEvent from a modal in a Discourse plugin. sirdavidoff is struggling to pass the toolbarEvent to a modal when a button is clicked on the top level of the toolbar, but it works when the button is under a menu.
pmusaraj suggests that the toolbarEvent should be available in the modal controller and recommends looking at how other modals handle this. However, sirdavidoff found that in the discourse-calendar plugin, the toolbarEvent is passed through setProperties().
keegan provides a solution by passing the event as a parameter to the action using action: (event) =>. This allows accessing the toolbarEvent in the modal. Joshua_Soileau confirms that this solution works and provides another example of how to implement it.
In summary, the solution involves passing the toolbarEvent as a parameter to the action, allowing it to be accessed in the modal.
My plugin inserts a button in the composer toolbar. This toolbar opens a modal, and when the modal is closed I want to add text to the post. Everything works perfectly except the last step, because I’m struggling to give the modal access to the composer.
If I put the button under a menu in the toolbar, everything works fine:
The toolbarEvent should be available in your modal controller (discourse-n8n-wf), you don’t need to pass it. You can also look at how other modals do this, for example, see discourse-post-event-builder.js.es6 in the poll plugin.
I found the file you referenced in the discourse-calendar plugin (couldn’t find it in the poll one), but there it seems like the toolbarEvent is indeed being passed in the action (through setProperties())?
Not sure if you’re still stuck on this but I’ve went down the rabbit hole of trying to figure out how to access the toolbar event from a modal as well, and I found you can pass the event as a parameter like this: