-
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
Post fields: extract title
from edit-site
to fields
package
#66940
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
const siteSettings: Settings | undefined = getEntityRecord( | ||
'root', | ||
'site', | ||
'', | ||
undefined | ||
); |
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.
This was const siteSettings = getEntityRecord( 'root', 'site' );
in the JavaScript version.
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.
I think for third-argument it's actually clearer because getEntityRecord
requires an id in general. But I believe we can make the fourth argument optional =something
in the type definition to avoid having to pass it.
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.
I've pushed cda6087
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.
@@ -9,13 +9,16 @@ import { __ } from '@wordpress/i18n'; | |||
*/ | |||
import type { BasePost } from '../../types'; | |||
import { getItemTitle } from '../../actions/utils'; | |||
import TitleView from './title-view'; | |||
|
|||
const titleField: Field< BasePost > = { | |||
type: 'text', | |||
id: 'title', | |||
label: __( 'Title' ), | |||
placeholder: __( 'No title' ), | |||
getValue: ( { item } ) => getItemTitle( item ), |
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.
It's nice that this basically means we're reusing the same field for DataForm and DataViews.
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.
And actions! For the record, I tested the "Duplicate" action in DataViews, DataForm, and Document Inspector.
Size Change: +238 B (+0.01%) Total Size: 1.82 MB
ℹ️ View Unchanged
|
4348bd5
to
f3ac637
Compare
statusField, | ||
======= | ||
titleField, | ||
>>>>>>> 4348bd5bbb (Extract title to fields package) |
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.
Conflict
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.
I didn't anticipate having to rebase the PRs after one has been merged — I thought git would be smarter :/
f3ac637
to
cda6087
Compare
Flaky tests detected in fec23a7. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11813599705
|
const siteSettings: Settings | undefined = getEntityRecord( | ||
'root', | ||
'site', | ||
'' |
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.
It looks like siteSettings
is undefined here, I think it's because of this empty key
. If I remove the key
parameter altogether, then siteSettings
works (i.e. calling getEntityRecord
with just root and site).
(Found because I'm working on #65426 😄)
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.
I just realised this works because the above PR makes key
optional in getEntityRecord
. Maybe this isn't ideal, although I'm not sure the best way around it.
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.
Oh, I see. I had to add the empty string for TypeScript not to protest, it wasn't there before. Thanks for providing a fix :)
Part of #61084
What?
This PR moves the
title
field definition fromedit-site
to thefields
package.Why?
In preparation for moving the whole
usePostFields
hook (conversation).Testing Instructions
Visit the Pages page and verify that the "Title" field still works as expected (search, visualization, edit).