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

Fixed crash when postType does not supports title & Removed title UI #5738

Merged
merged 1 commit into from Mar 26, 2018

Conversation

Projects
None yet
4 participants
@jorgefilipecosta
Member

jorgefilipecosta commented Mar 21, 2018

The selector getDocumentTitle did not check for null/undefined titles. That was the reason for the crash.
PostTypeSupportCheck was added to PostTitle component in order for it not to render when the title is not supported.

Fixes: #5621.

How Has This Been Tested?

Add a CPT that does not support title e.g:

function create_product_type() {
    register_post_type( 'acme_product',
        array(
	    'label'  => 'Product',
            'labels' => array(
                'name' => __( 'Products' ),
                'singular_name' => __( 'Product' )
            ),
            'public' => true,
            'show_in_rest' => true,
            'supports' => array( 'editor' ),
        )
    );
}
add_action( 'init', 'create_product_type' );

Create a new post, see that title field does not appear.
Save the post and open it. See no crash happens, in master editor would crash.

Fixed crash when postType does not supports title. Remove title UI wh…
…en post type does not supports it.

The selector getDocumentTitle did not checked for null/undefined titles. That was the reason of the crash.
PostTypeSupportCheck was added to PostTitle component in order for it not render when title is not supported.

@jorgefilipecosta jorgefilipecosta self-assigned this Mar 21, 2018

@jorgefilipecosta jorgefilipecosta requested a review from WordPress/gutenberg-core Mar 22, 2018

@noisysocks

noisysocks approved these changes Mar 26, 2018 edited

Code looks good. Verified that the title doesn't appear:

screen shot 2018-03-26 at 15 10 28

@jorgefilipecosta jorgefilipecosta changed the title from Fixed crash when postType does not supports title & Remove title UI to Fixed crash when postType does not supports title & Removed title UI Mar 26, 2018

@jorgefilipecosta jorgefilipecosta merged commit 05e1c9e into master Mar 26, 2018

2 checks passed

codecov/project 44.36% (+0%) compared to a62febf
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jorgefilipecosta jorgefilipecosta deleted the fix/crash-when-post-type-does-not-support-title branch Mar 26, 2018

@paulwilde

This comment has been minimized.

Show comment
Hide comment
@paulwilde

paulwilde Mar 27, 2018

Contributor

If the post type does not support a title, it would make sense to also remove it from the 'Table of Contents':

screen shot 2018-03-27 at 15 51 57

Contributor

paulwilde commented Mar 27, 2018

If the post type does not support a title, it would make sense to also remove it from the 'Table of Contents':

screen shot 2018-03-27 at 15 51 57

@aduth

This comment has been minimized.

Show comment
Hide comment
@aduth

aduth Mar 27, 2018

Member

@paulwilde This is a good point. Can you create a new issue for this?

Member

aduth commented Mar 27, 2018

@paulwilde This is a good point. Can you create a new issue for this?

@jorgefilipecosta

This comment has been minimized.

Show comment
Hide comment
@jorgefilipecosta

jorgefilipecosta Mar 27, 2018

Member

Thank you for the catch @paulwilde, I will try to submit a fix soon.

Member

jorgefilipecosta commented Mar 27, 2018

Thank you for the catch @paulwilde, I will try to submit a fix soon.

@miina miina referenced this pull request Apr 9, 2018

Merged

Add adventure custom post type #33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment