wp-shortcake / shortcake

Shortcake makes using WordPress shortcodes a piece of cake.
GNU General Public License v2.0
665 stars 143 forks source link

Make sure `render_edit` hook fires after media frame is created #729

Closed mattheu closed 7 years ago

mattheu commented 7 years ago

Following on from this ticket, I have been talking to @rahulsprajapati about how best to achive what he wanted.

Using setTimeout as you suggested works fine, however I think I agree with him that there could be a better solution that guarantees that his code is run at the correct time. Having another action shortcode-ui.after_set_action_update would be useful.

We currently have an actionshortcode-ui.render_edit, but shortcake renders the modal content inside a defer callback. Because of this I think it makes sense to add an extra action.

goldenapples commented 7 years ago

Oh, this makes a lot of sense.

I'm wondering if it makes more sense just to move the existing render_edit hook into the _.defer callback, so that functions as expected? Currently that hook fires at an indeterminate time which could be before or after the frame is available. Nailing it down to fire once the frame was rendered seems like it would be the desired behavior in any case I can think of.

mattheu commented 7 years ago

Moving the current action rather than a new action also makes a lot of sense. I have updated.