Skip to content

Commit

Permalink
publish on rename (#25206)
Browse files Browse the repository at this point in the history
  • Loading branch information
Addison-Stavlo committed Sep 10, 2020
1 parent 75ab85b commit 2ece5d6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/block-library/src/template-part/edit/name-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ export default function TemplatePartNamePanel( { postId, setAttributes } ) {
'slug',
postId
);
const [ status, setStatus ] = useEntityProp(
'postType',
'wp_template_part',
'status',
postId
);

return (
<div className="wp-block-template-part__name-panel">
<TextControl
Expand All @@ -28,6 +35,9 @@ export default function TemplatePartNamePanel( { postId, setAttributes } ) {
setTitle( value );
const newSlug = cleanForSlug( value );
setSlug( newSlug );
if ( status !== 'publish' ) {
setStatus( 'publish' );
}
setAttributes( { slug: newSlug, postId } );
} }
onFocus={ ( event ) => event.target.select() }
Expand Down

0 comments on commit 2ece5d6

Please sign in to comment.