-
Notifications
You must be signed in to change notification settings - Fork 846
WPCOM Block Editor: Update meta key name #17595
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
Conversation
E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-17595 This is an automated check which relies on |
creativecoder
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few questions...
Should we add a jetpack prefix to the post_meta key (e.g. _jetpack_last_editor_used) to avoid any potential Core or plugin conflicts?
What do you think about changing Jetpack\ClassicEditor to Jetpack\EditorType, Jetpack\RememberEditor, Jetpack\EditorClient, or similar. I think this would future proof it a little better, in case we add additional clients or expand it to work with the REST API.
I think the function classic_editor_can_edit_post_type from #17407 is actually meant to be block_editor_can_edit_post_type? It looks like it checks the block editor. If so, let's update that in this PR as well.
I was thinking about adding
Yes, changing
This is a hangover from the Classic Editor Plugin - it's namespacing it. Now we have a namespace, I think it can be renamed to |
|
As we want to try and get this into 9.1, I've moved it on to 'Needs Review'. |
retrofox
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested the patch and it works as expected. It picks up the current editor and stores it in the post meta key. I suggest holding on to get a 👍 from @Automattic/jetpack-crew folks.
After some discussion, we decided that it was probably beneficial to not tie the meta key for the last editor used to the one used by the Classic Editor Plugin. This simplifies the code because we don't need to check for the plugin being present, and means we can make the meta key hidden by prepending an underscore, as @jeherve suggested in the original PR.
0de5e63 to
528ff70
Compare
jeherve
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving again after a rebase to fix unrelated test failures.
creativecoder
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the updates @pablinos !
In testing, this saves the last editor loaded for the post in the post meta, as expected.
I did get into a weird state at one point, after first activating the classic plugin for a site, which the value was classic-editor for a post even though I had not yet loaded the classic editor for that particular post. But I couldn't replicate it again, so it may have just been a mistake in my testing.
It does make me wonder if updating the meta on update or publish would be better (though more difficult to achieve, if I recall from your earlier explorations), but that's something we can explore in a future change--this works well enough for what we need.
Hmmm, that does sound odd. I did get into an odd state where I went to edit the post using the classic editor and got warned about it having blocks. I clicked to load the block editor by accident and closed the browser. In this situation, the meta had already been updated to
I think we'd be able to update the meta as the post is saved, but Gutenberg will be using the API to do that, so we'd have to pass something through to make sure it's updated. Setting it as the editor is loaded should mean we always get the latest value, and it works the same in the Classic Editor Plugin. Let's see how it goes, and look to update it, if needs be. |
creativecoder
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-review with the latest changes using a jurassic.ninja site + the classic editor plugin. All working as expected.
✅ Loading the post with the classic editor gives a meta value of classic-editor
✅ Loading the post with the block editor gives a meta value of block-editor
✅ The meta is synced to wpcom
retrofox
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
After some discussion, we decided that it was probably beneficial to not
tie the meta key for the last editor used to the one used by the Classic
Editor Plugin. This simplifies the code because we don't need to check
for the plugin being present, and means we can make the meta key hidden
by prepending an underscore, as @jeherve suggested in the original PR.
Changes proposed in this Pull Request:
This PR changes the meta key to
_last_editor_used_jetpackand removes the logic to check the Classic Editor Plugin settings if the plugin is active.There is an associated WPCOM change in D50744-code
Testing instructions:
Create and save a post. Check that it has
_last_editer_used_jetpackset as post meta, and that the value is correct - eitherclassic-editororblock-editorTo see the value sync'd, apply D50744-code to your sandbox and set
JETPACK__SANDBOX_DOMAINto an appropriate value.Proposed changelog entry for your changes:
N/A - this is a tweak to a new feature. The changelog is the same as #17407