Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.7 metaboxes refresh and break functionality #3523

Closed
2 tasks
vinnyusestrict opened this issue Nov 16, 2017 · 6 comments · Fixed by #3616
Closed
2 tasks

Version 1.7 metaboxes refresh and break functionality #3523

vinnyusestrict opened this issue Nov 16, 2017 · 6 comments · Fixed by #3616
Labels
[Feature] Meta Boxes A draggable box shown on the post editing screen [Type] Bug An existing feature does not function as intended

Comments

@vinnyusestrict
Copy link

Issue Overview

My plugin adds a metabox to the Extended Settings side area. It contains a single input field and a get button, which triggers ajax actions to load information within (keyword information). However, the Extended Settings area refreshes even if there's a fetch going on, which basically aborts whatever was happening and reloads the metabox.

After spending 2 weeks getting my plugin to work with the iframes only to see them dropped (thankfully) in v1.7, I'm hesitant to do any work to accommodate for this quirk.

Also, I'm not sure what triggers the Extended Settings refresh, as it seems quite random. I've been editing the title and body of the test post in the hopes of getting the refresh to happen, but one thing I have not done is click publish or save draft..

Steps to Reproduce (for bugs)

  1. Add a simple side metabox with an input field (adding the code in functions.php is fine)
function gb_test_side_metabox_refresh(){
    add_meta_box( 'test-gutenberg-refresh', esc_html('test gutenberg refresh'), 'gb_test_render_metabox', 'post', $context = 'side', $priority = 'default', $callback_args = null );
}

function gb_test_render_metabox( $post ){ 
?>
    <input type="text">
<?php 
}

add_action( 'add_meta_boxes', 'gb_test_side_metabox_refresh' );
  1. Load an existing post or create a new one;
  2. Expand the side Extended Settings area
  3. Type something into the newly-created metabox
  4. Wait for the spinner to appear next to the top-most metabox in the Extended Settings area, indicating that the area will be refreshed;
  5. See that the input field is now empty.

Expected Behavior

The settings area should not be refreshed automatically, just like they're not in the classic builder.

Current Behavior

The bug causes the input field to be emptied, effectively negating any work that the user has done before saving.

Possible Solution

Screenshots / Video

step1
step2
step3

Related Issues and/or PRs

Todos

  • Tests
  • Documentation
@youknowriad youknowriad added [Feature] Meta Boxes A draggable box shown on the post editing screen [Type] Bug An existing feature does not function as intended labels Nov 16, 2017
@ephox-mogran
Copy link
Contributor

@vinnyusestrict I'm having difficult replicating this problem. The extended settings never refreshes for me. Can you shed any further light on whether it has happened more recently? And what you were doing? Thanks.

@shanejones
Copy link

I'm getting a similar issue to this using ACF with the Flexible Content Functionality.

@youknowriad
Copy link
Contributor

youknowriad commented Nov 21, 2017

I guess that's an issue related to the "auto-save" feature because any post save refreshes the metaboxes. But that's independent of the changes introduced in the "1.7" release.

Options we have:

  • Auto-save do not save the metaboxes if they are "focused". Doesn't take in consideration any async behavior triggered without the need to focus the "metaboxes" area.

  • Auto-save never save the metaboxes, only an "explicit" save does, which means an auto-save should keep the "dirty" status to true in this case.

  • Treat this kind of metaboxes as "metaboxes not supporting Gutenberg" and load the classic editor in this case.

Thoughts @aduth @pento @mtias

@vinnyusestrict
Copy link
Author

@ephox-mogran, Sorry, I don't know why mine refreshes or how to force yours to refresh.

@youknowriad, another option is to auto-save via ajax without reloading the area. How come the Classic editor auto-saves without reloading the whole page? Does it not save the custom metaboxes as well?

@youknowriad
Copy link
Contributor

Another option is to auto-save via ajax without reloading the area. How come the Classic editor auto-saves without reloading the whole page?

We're already auto-saving via AJAX, but I think we are assuming that the metaboxes HTML may change after save so that's why we're also updating the HTML, maybe we can just drop the HTML update. cc @BE-Webdesign

@aduth
Copy link
Member

aduth commented Nov 27, 2017

Expected Behavior

The settings area should not be refreshed automatically, just like they're not in the classic builder.

While I do suspect this is caused by auto-save, an auto-save in Gutenberg is more-or-less equivalent to a full "Save Draft" in the classic editor, in which case a refresh (more accurately, full page reload) would be expected. The difference is that in Gutenberg we are more aggressive with draft saves, since we expect to not have to do a full page reload, but metaboxes don't always work well within this assumption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Meta Boxes A draggable box shown on the post editing screen [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants