-
Notifications
You must be signed in to change notification settings - Fork 11
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
Handle Gutenberg Updates Live #9
Comments
@rmccue, @roborourke and I discussed potential options for this today and the conversation can be found here: https://hmn.slack.com/archives/C3CKS8LLR/p1591113944421600 (for internal HM folks) For this feature, we have two options:
|
For option 1. can you have the panel open while making changes that could cause it to need to update? If so then 1. is a non starter and we should aim for option 2 directly. |
Ah, fair point @roborourke - you can make edits while the PrePublishPanel is open. |
Short of live-polling the check status REST endpoint while the PrePublishPanel is open or subscribing to every post data update in the editor, there's no way to accurately reflect all possible updates made while this panel is open, so unless I'm missing something here, option 2 runs into the same problems as 1. I don't see a simple solution for this, but maybe a way for checks to register the object in the content model they want to subscribe to changes on, and running a debounced REST call whenever that changes, could be a solution? |
I also see the same issue with 1 and 2: You can edit the post during post saving or fetching the REST endpoint for the checks so the status could change. Option 1 (Save draft automatically)I believe that option 1 is the easiest as saving the post is quite easy with
Option 2 (REST Endpoint)Ideally, we would want to subscribe to changes in certain fields like @goldenapples said instead of relying on the panel opening. This would add a benefit: When the panel opens, the checks could have been already been checked. This change would involve:
PublicationChecklist\register_prepublish_check( 'article-type', [
'type' => 'article',
'run_check' => function ( array $post, array $meta, array $terms ) : PublicationChecklist\Status {
...
},
'fields' => [ 'category', 'meta.my_meta_key', 'content' ]
] ); This way, the check could subscribe to changes to those fields and as soon as they change and could fetch the REST API endpoint for checks. The hardest part with this option would be sending the data to the endpoint. Some considerations would involve to debounce the fetch so it's not triggered after every key stroke. Option 3 (JS API)There's another alternative: Allow developers to duplicate logic in JS by letting them to update live the checks. We did something like this in The Sun. Developers could even choose to pass a I don't think this is a bad thing per se if it's well documented and it adds a lot of flexibility. |
are you guys still working on this? or should we find a workaround? |
Currently, the publishing checklist uses the backend as the source of truth for updates to the publishing checklist. However, this has severe limitations and breaks expectations in Gutenberg.
To get proper updates based on live data that the editor has currently entered, you have to either completely duplicate the logic from PHP in React, or the editor has to "Save Draft" before they can see the checklist update. This is problematic in multiple ways:
I propose that the plugin should use live, edited data as the source of truth. This could mean writing the checks in React, or it could mean sending out for updated data from PHP whenever the Publish panel is open.
The text was updated successfully, but these errors were encountered: