humanmade / post-cloner

Post Cloner plugin
3 stars 2 forks source link

Gutenberg editor breaks with custom post stati #16

Closed tcrsavage closed 4 years ago

tcrsavage commented 5 years ago

When a custom post status is registered, Gutenberg edit screens fatal error due to bad render handling.

Screen Shot 2019-03-11 at 15 43 23
Invariant Violation: DisplayPostCloningStatus(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.
    at invariant (http://motogp.servus.local/wp-includes/js/dist/vendor/react-dom.js?ver=16.6.3:49:15)
    at reconcileChildFibers (http://motogp.servus.local/wp-includes/js/dist/vendor/react-dom.js?ver=16.6.3:13883:13)
    at reconcileChildren (http://motogp.servus.local/wp-includes/js/dist/vendor/react-dom.js?ver=16.6.3:14202:28)
    at mountIndeterminateComponent (http://motogp.servus.local/wp-includes/js/dist/vendor/react-dom.js?ver=16.6.3:14764:5)
    at beginWork (http://motogp.servus.local/wp-includes/js/dist/vendor/react-dom.js?ver=16.6.3:15187:16)
    at performUnitOfWork (http://motogp.servus.local/wp-includes/js/dist/vendor/react-dom.js?ver=16.6.3:17944:12)
    at workLoop (http://motogp.servus.local/wp-includes/js/dist/vendor/react-dom.js?ver=16.6.3:17984:24)
    at renderRoot (http://motogp.servus.local/wp-includes/js/dist/vendor/react-dom.js?ver=16.6.3:18070:7)
    at performWorkOnRoot (http://motogp.servus.local/wp-includes/js/dist/vendor/react-dom.js?ver=16.6.3:18961:7)
    at performWork (http://motogp.servus.local/wp-includes/js/dist/vendor/react-dom.js?ver=16.6.3:18873:7)

To reproduce

Register a custom post status, assign the status to a post, edit the post with gutenberg

    register_post_status( 'imported', [
        'label'                     => _x( 'Imported', 'post status' ),
        'public'                    => false,
        'exclude_from_search'       => true,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'label_count'               => _n_noop( 'Imported <span class="count">(%s)</span>', 'Imported <span class="count">(%s)</span>' ),
    ] );
tcrsavage commented 5 years ago

Can be bypassed by adding the custom status to the clonable stati

add_filter( 'post_cloner_clonable_statuses', function( $stati ) {
    $stati[] = 'imported'; 
    return $stati 
} );
pdewouters commented 4 years ago

I can't reproduce this. I have registered the custom status, and set a post to this status with WP CLI. But I don't get an error in Gutenberg.

Screenshot 2020-07-30 at 11 44 20
roborourke commented 4 years ago

@pdewouters cheers for checking, looks like this must have been fixed in a subsequent version of gutenberg