-
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 all commits
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
activateTheme, | ||
createNewPost, | ||
insertBlock, | ||
pressKeyWithModifier, | ||
saveDraft, | ||
} from '@wordpress/e2e-test-utils'; | ||
|
||
describe( 'Post Title block', () => { | ||
beforeAll( async () => { | ||
await activateTheme( 'twentytwentyone-blocks' ); | ||
} ); | ||
|
||
afterAll( async () => { | ||
await activateTheme( 'twentytwentyone' ); | ||
} ); | ||
|
||
beforeEach( async () => { | ||
await createNewPost(); | ||
} ); | ||
|
||
it( 'Can edit the post title', async () => { | ||
// Create a block with some text that will trigger a list creation. | ||
await insertBlock( 'Post Title' ); | ||
|
||
// Select all of the text in the post title block. | ||
await pressKeyWithModifier( 'primary', 'a' ); | ||
|
||
// Create a second list item. | ||
await page.keyboard.type( 'Just tweaking the post title' ); | ||
|
||
await saveDraft(); | ||
await page.reload(); | ||
await page.waitForSelector( '.edit-post-layout' ); | ||
const title = await page.$eval( | ||
'.editor-post-title__input', | ||
( element ) => element.value | ||
); | ||
expect( title ).toEqual( 'Just tweaking the post title' ); | ||
} ); | ||
} ); |
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)