-
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
PostFormat suggestion: fix double parsing #56255
Conversation
Size Change: -13 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
Flaky tests detected in 19bb9fe. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6905482309
|
const blocks = this.props.blocks; | ||
const blocks = | ||
this.props.getEditedPostAttribute( 'blocks' ) || | ||
parse( this.props.getEditedPostContent() ); |
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.
There's something terribly wrong here on the native side, but that's out of the scope of this PR. The blocks in the block editor store should be available when the editor is ready, yet they aren't (causing some test failures). I've just restore the logic from getEditorBlocks
, though obviously it's going to parse the content here.
supportedFormats: themeSupports.formats, | ||
}; | ||
}, [] ); | ||
const suggestedFormat = getSuggestedPostFormat( blocks ); |
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 might be more performant to derive value inside the mapSelect
, so we don't re-render the component on every block change.
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.
Right, will have to revert to using the selector
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.
Here's my alternative PR #56679.
const suggestion = getSuggestion( | ||
supportedFormats ?? [], | ||
getSuggestedPostFormat( blocks ) | ||
); |
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.
Same here.
return null; | ||
} | ||
export function getSuggestedPostFormat() { | ||
return null; |
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.
We should properly deprecate this selector.
This is cool. Thanks for noticing this duplication. |
@Mamaduka You fixed this one entirely in the end right? |
What?
#52417 introduced a performance regression when the sidebar is open: the post is now parsed twice on load.
Why?
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast