-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 Title: Implement debounced title saving and fix title retrieval for post context #68431
Post Title: Implement debounced title saving and fix title retrieval for post context #68431
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @0x8sksr, @ivarsm. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
@@ -50,12 +51,20 @@ export default function PostTitleEdit( { | |||
}, | |||
[ isDescendentOfQueryLoop, postType, postId ] | |||
); | |||
const [ rawTitle = '', setTitle, fullTitle ] = useEntityProp( | |||
const [ rawTitle = '', , fullTitle ] = useEntityProp( |
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 am seeing 2 commas here. Is this intended?
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. The second value, setTitle, is no longer needed, so it is skipped in the destructuring assignment.
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 yes, got that. Thank You,
Thanks for working on this, @yogeshbhutkar! I don't think using the Changes to a post or page should not persist without the user's direct action — saving a post. |
@yogeshbhutkar, let's continue the discussion on possible solutions in the issue. |
Sure, thanks @Mamaduka. I thought this wouldn't be a practical solution as well, but, I don't think it's possible to keep it synced with the previews until and unless we manually update the |
What, Why & How?
As noted in the file packages/block-library/src/post-title/index.php, the context's
Post ID
was removed from theget_the_title()
function. However, I believe the context's Post ID should be utilized to make the block functional even outside the Query Loop block.To address the issue of unsynced previews, I’ve implemented a solution that directly dispatches changes to the
post-title
block. This ensures that updates appear in the preview tab, providing a consistent and synced experience.That said, directly dispatching changes in previews might not always align with the purpose of previews, which are meant to reflect unsaved changes. However, given that significant modifications to the
core/post-title
block are rare, this approach could be acceptable as it prioritizes a fully synced and cohesive look.Testing Instructions
edit.js
save.js
core/post-title
block as an inner block.preview
and works outside theQuery Loop
.Screencast
Before
Screen.Recording.2024-12-31.at.12.04.52.PM.mov
After
Screen.Recording.2024-12-31.at.12.02.25.PM.mov
Closes: #68369