Skip to content
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

Make the post title block editable #27240

Merged
merged 3 commits into from
Nov 26, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,15 @@ function Editor() {
const {
__experimentalGetTemplateInfo: getTemplateInfo,
} = select( 'core/editor' );
entitiesToSave.forEach( ( { kind, name, key } ) => {
entitiesToSave.forEach( ( { kind, name, key, title } ) => {
const record = getEditedEntityRecord( kind, name, key );

if ( 'postType' === kind && name === 'wp_template' ) {
const { title } = getTemplateInfo( record );
return editEntityRecord( kind, name, key, {
status: 'publish',
title,
} );
if ( kind === 'postType' && name === 'wp_template' ) {
( { title } = getTemplateInfo( record ) );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a weird notation. Are the parenthesis necessary?

Copy link
Contributor

@ntsekouras ntsekouras Nov 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

const edits = record.slug
? { status: 'publish', title: record.slug }
: { status: 'publish' };

editEntityRecord( kind, name, key, edits );
editEntityRecord( kind, name, key, {
status: 'publish',
title: title || record.slug,
} );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this supposed to do? I mean the whole function closeEntitiesSavedStates? Why are we setting status and title here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think setting the status ensures that auto-draft templates are set to publish.

Title part is needed to give a title for wp_template_part. Since they don't have custom titles, they are using the slug as a title in every case. On the other hand we want to preserve the title if the entity has one. (Basically everything except wp_template_part

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So something to be done before "saving" right. I don't understand why it's in closeEntitiesSavedStates

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the close prop is misnamed. It should be something more like preSaveCallback

} );
}
setIsEntitiesSavedStatesOpen( false );
Expand Down