[wp-trac] [WordPress Trac] #52933: Error in browser console when newly published post is previewed a second time
WordPress Trac
noreply at wordpress.org
Sat Apr 17 15:47:47 UTC 2021
#52933: Error in browser console when newly published post is previewed a second
time
----------------------------+-----------------------------------
Reporter: garethhadfield | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.8
Component: Editor | Version:
Severity: normal | Resolution:
Keywords: | Focuses: javascript, rest-api
----------------------------+-----------------------------------
Comment (by Rahmohn):
I've tested this and can reproduce the issue too.
The issue happens if there is already an autosave and the user clicks in
"Preview in new tab" because this button
[https://github.com/WordPress/gutenberg/blob/3da717b8d0ac7d7821fc6d0475695ccf3ae2829f/packages/editor/src/components
/post-preview-button/index.js#L174 always tries to autosave the post]. So
another way to reproduce this issue is by clicking on "Preview in new
tab", reload the page and try to preview again.
Other than that, Autosaves controller [https://github.com/WordPress
/wordpress-develop/blob/5e8b165a54be9f72d3b323a81d5ba1e262b6f194/src/wp-
includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php#L376
deletes the autosave when the post data is the same]. So the next time the
user tries to preview the issue doesn't happen.
It's not clear to me the best approach to fix it. We can prevent the
"Preview in new tab" button to send the request when the content hasn't
changed. The behavior would be like the "Update" button. The second
approach is changing the Autosave controller to return the previous
autosave if the content is the same instead of a Bad Request (HTTP 400).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/52933#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list