Skip to content
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

Block validation / pre-publishing checks #1

Open
troychaplin opened this issue Aug 17, 2023 · 2 comments
Open

Block validation / pre-publishing checks #1

troychaplin opened this issue Aug 17, 2023 · 2 comments
Assignees
Labels
Chef de Cuisine This recipe is for seasoned (see what I did there?) block developers Recipe

Comments

@troychaplin
Copy link

The lack of validation in Gutenberg components is disappointing. I've setup a series of pre-publishing checks for some core blocks but am having an issue related to inner blocks.

Take the core/buttons for example. I have pre-publishing checks that lock post saving until text and a link have been set on a button. This works well but only when used as a parent block. When I use core/buttons as an inner block in a custom block I can't see to get those same pre-publishing checks to work.

A solid example of this would be a great idea.

In addition to this I am using createErrorNotice to give users a heads up that there's an issue with their block. Unfortunately that item is positioned at the top of the content area and isn't in view when a user is working with blocks further down the page. To date I've been unable to find a way to add position: sticky to that notice so it's at least in view, but what I am ultimately trying to figure out is if I can use createErrorNotice or another method to display the block errors right inside the main block container.

So to summarize, my idea would be to create method to run pre-publishing checks regardless of whether or not the block is a parent or innerblock, and to display a message to the user about the error in the block container.

@ryanwelcher ryanwelcher added the Chef de Cuisine This recipe is for seasoned (see what I did there?) block developers label Aug 18, 2023
@ryanwelcher ryanwelcher self-assigned this Aug 18, 2023
@troychaplin
Copy link
Author

troychaplin commented Aug 18, 2023

@ryanwelcher added an example of what I've currently got in place. I'm checking a few items here, and when a check isn't met there's a createErrorNotice as well as a additional error information in a PluginDocumentSettingPanel. Perhaps this would be a good start point that can be expanded upon for a variety of other blocks and checks and made far better for the user.

It's broken down in to 3 files here -- https://github.com/troychaplin/gutenberg-resources/tree/master/pre-publishing

Screenshot 2023-08-18 at 3 54 51 PM

@ryanwelcher
Copy link
Owner

We took a look at this on a stream and I have uploaded the video to YouTube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Chef de Cuisine This recipe is for seasoned (see what I did there?) block developers Recipe
Projects
None yet
Development

No branches or pull requests

2 participants