Closed elliott-stocks closed 6 years ago
Does the render_destroy
hook do what you want? It looks like it's not currently being called if the media modal is closed without inserting to the editor, but it probably should be.
Thanks, @goldenapples. I'm using that already, but as you mentioned it isn't called on modal close.
Adding this hook to the deactivate
method seems like it would work, thoughts?
Adding this hook to the deactivate method seems like it would work, thoughts?
Seems feasible. However, since we're overriding the core media controller, I'd be wary of overloading it too much. What do you think about attaching it in the one-time "close" callback here, so that the hook only gets called in the shortcode UI frame and not in every media controller?
~I would keep the same shortcode-ui.render_destroy
hook in the one-time "close" callback, rather than introducing a separate hook. Thoughts?~
Never mind. Found my answer in #797
Fixed in #797 - thanks!
I noticed this todo on the select2 field. But as far as I can tell, the destroying on select2 doesn't actually happen;
I need to be able to detect when the modal closes, to trigger an action.
This is the code I used -
However this doesn't work, am I possibly calling it to early?
I'm thinking would it not be easier to add deactivate method on the media controller, then trigger a hook?
On
MediaController
initialize -this.on( 'deactivate', this.deactivate, this );
Then the function that triggers a hook -
I'm happy to open a PR for this, if you think it'd make sense? Would then resolve the select2 UI issue too.