-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Metaboxes: Trigger tinymce save before saving metaboxes #8762
Conversation
@youknowriad Your testing instructions also work for me on the Did your testing instructions fail for you on the The change itself seems logically reasonable; just want to confirm the change fixes a real test case. |
@danielbachhuber Which version of ACF are you using? |
I'm using the one in the repository, I suspect they did something on their end for the |
@youknowriad I installed |
🤷♂️ I'd have sworn I tested without my changes and it broke :P but anyway maybe we can ask the people who asked for this in the issue Edit: you already did :) |
86324a9
to
6de5e4f
Compare
@youknowriad This pull request fails for me using the test metabox in #7176 (comment) However, if I call |
Thanks for the snippet, I'll give it a try when I have some time. |
It's weird because I can't break it with or without the PR. Maybe it's browser specific, but I tried in both Firefox and Chrome. |
Or maybe it's a race condition or some deeper bug? |
I'm closing the PR for now and I think we should close the issue until we can break it consistently :P or maybe you can try a fix since you can reproduce |
I'd like to keep the issue open because closing the issue doesn't make the problem go away. I don't have any ideas on what the fix might be though. |
I've dug into this a bit, but I feel a TinyMCE expert would have better luck figuring out the correct fix. I posted some notes on reproducing with our plugin that uses wp_editor in meta boxes below the edit post body in this related issue: #7176 Some notes:
TL;DR: With Gutenberg, this never happens. Once we figure out the best way to trigger TinyMCE to update all of the wp editor textareas (or write a new way), we should probably insert it into the bottom of this method in post.js: https://github.com/WordPress/WordPress/blob/bdbaccce379b9db3e8a1a6e5c7a0c6a91ae197bf/wp-admin/js/post.js#L334 I don't know where the equivalent of that file is in the Gutenberg plugin. I hope this helps. |
Another note, it's very possible that certain plugins like Advanced Custom Fields have coded their own solutions for this, which is why the problem might have "gone away" in certain tests. Ideally, if someone uses wp_editor in a meta box, it should get posted on save post without having to add additional JavaScript to fix this bug. |
Hmmm, There may be a problem where the "Text" editor tab is used and |
@azaozz if I understand you correctly the only way for the metaboxes content to be saved is via js. Is there a snippet that you can point us to? This issue seems to involve only tinymce, ie the Visual tab. Content entered via the text editor tab will save. |
@youknowriad This issue definitely still exists. @danielbachhuber I ran a test using your snippet for a metabox and was able to get TinyMCE Toolbar1 items to save, but if I removed your gutenberg/edit-post/store/effects.js Lines 68 to 70 in edefa5e
|
@pbrocks I agree this is still an issue. fwiw I moved away from the patched version and as a workaround I believe that the issue doesn't show up if you use the source rather than visual editor. |
Actually just tested on an out of the box Gutenberg and had decent results with html and non-tinymce metabox window. Screencast here: |
It appears that @azaozz has a point regarding the Text tab vs Visual tab. I was able to successfully use the editor and the full range of toolbars 1 and 2 in the metabox editor, as long as when I clicked save or update, I was on the text tab, ie seeing the html as text. Screencast showing metabox editor saving html when viewed as text |
closes #7176
The idea is to fix saving
wp_editor
s used in metaboxes.Testing instructions