-
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
Editor: Hide block editor warnings for pattern previews #68701
base: trunk
Are you sure you want to change the base?
Editor: Hide block editor warnings for pattern previews #68701
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. |
Thanks for the review @Mamaduka. Incorporated the suggested changes in the latest commit. |
#68131 suggests hiding all interactive elements from the pattern preview. For example, should we hide placeholders in the Query Loop block as well? |
I’ve implemented a change in the latest commit to hide all the placeholders except the media placeholders. The media placeholders are quite widely used to represent an insertable image and in my opinion should not be removed from the previews as well.
I've tried demonstrating this with Group and Query Block Placeholders. CC: @t-hamano |
…sed on illustration presence
I'm not sure about the placeholders. They could signal that the template/pattern needs to be finished. We shouldn't hide too much content and diverge previews from edit canvas. cc @afercia, @karmatosed |
Ideally, previews should show what is rendered once 'finished' i.e. how the pattern will actually look like on the front end. The whole purpose of the preview cards is to allow users to choose a pattern based on functionality and design. Previews that show the editing UI don't make much sense to me. |
What do you think about a JS approach? That is, add the following changes to the diff --git a/packages/block-editor/src/components/block-list/block.js b/packages/block-editor/src/components/block-list/block.js
index 29f8a97b03..9046774ee8 100644
--- a/packages/block-editor/src/components/block-list/block.js
+++ b/packages/block-editor/src/components/block-list/block.js
@@ -761,6 +761,10 @@ function BlockListBlockProvider( props ) {
return null;
}
+ if ( isPreviewMode && ! isValid ) {
+ return null;
+ }
+
const privateContext = {
isPreviewMode,
clientId, This approach can be extended to other block placeholders etc if needed. export default function Edit() {
const isPreviewMode = useSelect( ( select ) => {
return select( blockEditorStore ).getSettings().isPreviewMode;
}, [] );
if ( isPreviewMode && someCondition ) {
return null;
}
// ...
} |
That would increase the number of changes we'll have to make. Placeholder examples can introduce unnecessary block editor store subscriptions, which affects loading and typing performance. I'm trying to revert something similar via #68690 in favor of CSS. |
I believe I’ve addressed all the feedback provided so far. Since the PR is still awaiting approval, is there anything else I need to do on my end? |
What, Why and How?
This PR addresses the issue of warning interactive elements being displayed within IFrame Previews in the Preview Components. It was concluded that these warnings are not required to be rendered in Previews. This change hides the warnings to improve the IFrame Previews' visual consistency and user experience.
Testing Instructions
Screenshots
Closes: #68131