-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Call tinyMCE.triggerSave() before sending metabox data #7176
Comments
also currently experiencing this problem. |
workaround:
where |
no code snippet as such (already replaced with above workaround), but adding any metabox that contains an instance of also, #8762 mentions ACF, which i'm not using. |
I put together a code snippet:
|
See conversation in #8762 (comment) for the failed attempt at fixing the issue. |
@danielbachhuber thanks for staying on top of it |
So the current state is that Gutenberg will not save content from @krisgale Unfortunately I can't get your workaround to correctly work.
But the |
important note per the above ^ |
@danielbachhuber has this bug been fixed with a change in Version 3.9 or 3.8? (I think with 3.7 the issue has existed) Because after the newest update it seams to work now. |
@michakrapp I'm not sure whether the issue has been fixed accidentally. When we worked on this last, we weren't able to reproduce the issue reliably: #8762 (comment) |
Strange thing - after the update it has been working a few times. But I can confirm that call |
Hello, Our users experience a similar problem. They're using Meta Box plugin to create repeatable editors. The data is not saved correctly. Details are here. I tested and see that when the editor in the Visual mode, the content is not saved. When it's in Text mode, it seems to work fine. I tried calling Thanks |
I am able to recreate this issue with our memberlite-elements plugin. It adds a few wp_editor instances into the meta boxes below the page. When I click to update the page, the meta box fields aren't saved. When I debugged, it's because the $_POST['field_name'] value was not updated. It seems that TinyMCE would update this before the post got saved and the suggestion solution here would work. I tried typing I am using WP 5.0-beta3-43878, Gutenberg Version 4.2.0, Chrome FWIW here is where we insert our editor: Here is where we process it. It fails on this line since the POST content is empty. Note that this plugin is meant to work with the Memberlite theme, but does still work (in terms of saving values) with Twenty* themes and fails with a Twenty* theme active. Do we need a better minimal example? Do we need someone to dig into this further and look for the fix? Let me know. I might have time. |
Wondering if this will be fixed in WP Core. Currently, any meta boxes with wysiwyg editors don't save in the block editor, and the promised meta box compatibility flags do not work either: meta boxes marked as incompatible are simply skipped for output, rather than falling back to the classic editor. |
@robincornett I suspect that this will be fixed in WP Core when the issue is understood fully. In my view this is related to TinyMCE not loading correctly for Metaboxes. That is a developer concern. For users, however, it may be helpful to know that Metaboxes will save correctly and fully if done using the Text tab, not Visual. That is, if you make all of the changes that you wish using the Visual tab, ie using the TinyMCE editor, and you switch to the Text tab, meaning you will see the text rendering of the html markup, when you click Publish or Update, the data in the metaboxes, including the markup, will save. Because of I am confident that this will be corrected in Core, but it will take someone who understands the waterfall of javascript in order to place the |
Thanks, @pbrocks--I get that it will theoretically be fixed in Core, but at the moment, I'm blocked on updating a plugin because of this issue (telling users to use the text tab isn't a great option for me) combined with no backwards compatibility in place yet. I hate to tell my users that they have to add the Classic Editor plugin just to keep using the plugin they've been using for an extended period of time, but right now that is all I can do. My concern is as a developer, not as a user. |
I understand (about 5.0.1), although that's unfortunate with the current state of the incompatible metabox notices--this would mean I need to go ahead and update my plugin(s) with the metaboxes marked as incompatible with the block editor--so users will be told to install the Classic Editor. Even if this is fixed in 5.0.1, users who've encountered this will have activated the Classic Editor based on the warnings; I wonder how many will bother deactivating it, especially since the warning disappears in the Classic Editor once the metabox has been marked as compatible with the block editor. It seems like affected users may enable the Classic Editor and then never know to leave it, even if they wanted to, once the compatibility warning disappears. I realize that the metabox notifications are a separate issue, but these two together are a concern to me. |
@robincornett That's not the only thing that's not compatible with previous plugins with Gutenberg. And the solution has always been the classic editor until the plugin is made compatible. So I don't think it will have a big impact. |
@youknowriad Sure, I must have written it badly ;) I've tested with Gutenberg (from the zip) active. And it wasn't working. Then, for comparison, I've deactivated Gutenberg and tested again, and it worked with WP4.9.8. |
@webmandesign Maybe it's fixing one incompatibility (the triggerSave call) and we're missing another one. |
@azaozz Aside the |
Just a note: the fix/PR works with Gutenberg active running 5.0RC, but not trunk (which I believe is still equivalent with 4.9.8, right?). So some difference between 5.0 and trunk is making the fix not work (outside of the RC), it appears. |
@youknowriad That may be possible.
So, I think we can rule out WebMan Amplifier issue here? Maybe, is there any JS action triggered when Gutenberg post is being updated? So I can use it to hook |
@robincornett Interesting and also good news I'd say. Maybe it's related to the TinyMCE config alignments we did recently. |
@webmandesign Could you test with 5.0 RC and this plugin to see if it fixes the issue? |
@youknowriad Yes, I've done that immediately as I saw @robincornett 's comment. And I can confirm it works perfectly fine now and the issue is fixed! Great catch there @robincornett! So, the combination of WP5.0RC + Gutenberg from zip works OK and fixes the issue. |
Awesome, this means we can merge the PR once approved and close this issue |
The other thing is that when the "default" The reason is that if the user has edited something in Text, it will be overridden by the editor instance (the hidden Visual tab). Best is to always use: var editor = tinymce.get( 'my-editor-id' );
if ( ! editor.isHidden() ) {
editor.save(); // this also returns the cleaned up html
} |
Thank you so much for looking at this ans providing compiled zip file for testing @youknowriad ! |
@azaozz Interesting, since we don't control the TinyMCE instances in Gutenberg, is there a way to retrieve all the instances in a given DOM container? |
TinyMCE keeps a collection of the instances, in In Gutenberg, only the Classic Block instance is "exposed" that way. |
CMB2 has added a fix for this in their plugin now; their solution may be worth examining. I'm implementing it for my own work and it is working in 5.0RC without Gutenberg active. |
@youknowriad @azaozz I can confirm, the fix does not override anything during post saving even when in "Text" mode of TinyMCE. I've tested with 2 different TinyMCE editors within 1 metabox, switching between modes, trying different combinations for both. Everything works perfectly fine. Would be great to get this with WP5.0 ;) |
Do you know if this is still the plan? I understand feature freeze but this is a back-compat fix and seems like feature freeze should not stop it. If it does get punted to 5.0.1 what is the recommended course of action for plugin developers? Sniff out 5.0 specifically and manually call a |
Also: preliminary testing confirms the combination of the zip file above and the latest 5.0RC (but not 4.9.8) does resolve the problem for us with Pods Framework. Many Imaginary Internet Points for this fix landing in 5.0 because it makes one of my own issues evaporate :D. |
Our metabox doesn't work correctly with the new editor because of WordPress/gutenberg#7176.
Bug report: https://metabox.io/support/topic/data-are-not-saved-into-the-database/ Issue: WordPress/gutenberg#7176 The fix is based on CMB2 fix (CMB2/CMB2#1190) and the PR(WordPress/gutenberg#12568) When the PR is merged into core/Gutenberg, this fix should be removed.
closed by #12568 |
Prior to sending metabox data for save, we need to call
window.tinyMCE.triggerSave()
to update any<textarea>
fields controlled bywp_editor()
instances.If TinyMCE is used on a
<textarea>
field, then the data doesn't end up in the actual<textarea>
until a save is triggered.Originally #6293
The text was updated successfully, but these errors were encountered: