Fields: Fix postContentInfoField when there are edits#76901
Fields: Fix postContentInfoField when there are edits#76901ntsekouras merged 3 commits intotrunkfrom
postContentInfoField when there are edits#76901Conversation
| // When a post is being edited, core-data stores content as a lazy | ||
| // serialization function rather than a string. | ||
| // @see `getEditedPostContent` selector - https://github.com/WordPress/gutenberg/blob/trunk/packages/editor/src/store/selectors.js#L919 | ||
| const rawContent = item.content as |
There was a problem hiding this comment.
I wasn't sure if we want to update CommonPost to include the case of the edited entity. What do you think @oandregal?
In that case we'd need to update a few places in other fields to make TS happy.
There was a problem hiding this comment.
can we create a new type (BasePostWithEditedEntity or something similar) to be used in this field?
There was a problem hiding this comment.
I saw the function is attached here, but there's no corresponding type anywhere.
There was a problem hiding this comment.
BasePostWithEditedEntity sounds good.
|
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. |
Mamaduka
left a comment
There was a problem hiding this comment.
Left two minor (optional) notes, but the fix looks good. Thanks, Nik!
| const rawContent = item.content as | ||
| | BasePost[ 'content' ] | ||
| | ( ( record: any ) => string ); |
There was a problem hiding this comment.
Question (non-blocking): Do you think we also need to adjust the type upstream, or will that just make it more complex? Currently, it accounts for raw attributes edits and records from the server.
|
Size Change: +15 B (0%) Total Size: 7.73 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in b4e4223. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23740867623
|
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: oandregal <oandregal@git.wordpress.org>
What?
I noticed that post content field doesn't display the word count and reading time when we have the
Editor Inspector: Use DataFormexperiment enabled in inspector controls.This happens because we the content of an edited entity is a function to avoid serialization before saving to avoid this possible expensive operation based on the content size, and the field wasn't checking for that case.
This PR fixes that by following suite with the existing component (without the experiment). Existing behavior though and therefore this PR kind of defeat the purpose of trying to avoid the serialization. Should we consider handling this differently - not showing this info when there are edits? 🤔
Noting that in order to see the post info while you're editing, you need to specifically change to the
posttab, after selecting/creating a block. See below:Screen.Recording.2026-03-30.at.11.57.40.AM.mov
Testing Instructions
Editor Inspector: Use DataFormexperimentposttab againBefore
before.mov
After
after.mov