-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 ) ); | ||
} | ||
|
||
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, | ||
} ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this supposed to do? I mean the whole function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think setting the Title part is needed to give a title for There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess the |
||
} ); | ||
} | ||
setIsEntitiesSavedStatesOpen( false ); | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes because
title
is declared above. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Assignment_without_declaration)