Gutenberg: Add a filter to force post to refresh on save

Created on 19 Sep 2018  路  6Comments  路  Source: WordPress/gutenberg

Is your feature request related to a problem? Please describe.
When you save a post in Gutenberg, all of the saving happens with AJAX and the page does not refresh. This creates a slick user interface, but it can lead to some problems, such as:

  • If you have metaboxes that only appear on some page templates, a user will select the page template, save the page, and not see the metabox. They have to refresh the page to see the metabox, or leave the editing page and return to it. This is confusing and bad user experience.
  • Some plugins/metaboxes crunch some data on save, and display new data after refresh. For instance, I have a plugin where users enter in a start time and end time for an event. When the post is saved, the plugin calculates the event duration based on those times, and displays it to the user. That doesn't get displayed unless the page refreshes.

Describe the solution you'd like
Provide a filter or setting that forces posts to refresh on save.

Describe alternatives you've considered
Some of these problems could be overcome by writing AJAX that, for instance, runs when a user changes the page template to automatically add any meta boxes. Eventually, that's probably a reasonable solution. In the short term, though, being able to force a refresh on save would fix compatibility issues in a lot of plugins.

[Feature] Meta Boxes [Status] Not Implemented

Most helpful comment

WordPress currently does a full page refresh on save, so why is performance an issue here? I was not suggesting a refresh on autosave, only a refresh when the user saves a post.

Some plugin authors will update their plugins soon, and others might not ever update them. It seems reasonable to offer an alternative to manually refreshing in situations where a refresh is needed. The metaboxes on different page templates is an especially common situation that is going to be very frustrating for users.

All 6 comments

Forcing the entire editor to refresh on save to accommodate plugins that expect a full page refresh isn't an acceptable solution鈥搃t's a pretty serious performance hit to do a full refresh on every save, never mind every autosave.

As you mention: it would be appropriate for these plugins to update/refresh their data with AJAX when a post is saved. I don't think a filter that allows metaboxes to force a full editor refresh is a good intermediate solution, as it will degrade the entire editor experience because of one/a few unoptimised plugins.

WordPress currently does a full page refresh on save, so why is performance an issue here? I was not suggesting a refresh on autosave, only a refresh when the user saves a post.

Some plugin authors will update their plugins soon, and others might not ever update them. It seems reasonable to offer an alternative to manually refreshing in situations where a refresh is needed. The metaboxes on different page templates is an especially common situation that is going to be very frustrating for users.

Gutenberg is a more full-featured editor than the existing, Classic editor so my understanding is that initialisation takes more CPU. We're working toward asynchronous parsing of the content and other performance improvements, but even if Gutenberg were faster than the classic editor to load in every way, it's still wasteful to refresh because of unoptimised plugins.

For plugin authors to take advantage of this new filter they'd need to update their plugin. I'd rather see them update to a model more compatible with Gutenberg's editing paradigm.

So I ran into this problem too and needed to come up with my own solution, here it is if anyone needs it:
https://wordpress.stackexchange.com/questions/319054/trigger-javascript-on-gutenberg-block-editor-save/319071

Forcing the entire editor to refresh on save to accommodate plugins that expect a full page refresh isn't an acceptable solution鈥搃t's a pretty serious performance hit to do a full refresh on every save, never mind every _autosave_.

As you mention: it would be appropriate for these plugins to update/refresh their data with AJAX when a post is saved. I don't think a filter that allows metaboxes to force a full editor refresh is a good intermediate solution, as it will degrade the entire editor experience because of one/a few unoptimised plugins.

So is there any chance we can get that feature implemented, or is it on any roadmap? The ability to refresh just one metabox's content on save?

I think that indeed this is a UX and performance issue to reload the full page for update post content / meta.
But it would be great to have access to an event to reload plugins / block content when the page is saved.
Currently, if you set data in a metabox, the user will have to save + refresh the page to be able to access this data in the blocks... This is a UX issue too ...

Was this page helpful?
0 / 5 - 0 ratings