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 JSON schema: Update shadow definition #58910

Merged
merged 3 commits into from
Feb 12, 2024
Merged

Conversation

t-hamano
Copy link
Contributor

@t-hamano t-hamano commented Feb 10, 2024

Follow up #58306

What?

This PR updates the definition of the shadow property in the block.json schema.

Why?

Current schema allows boolean or object. I think the reason object is allowed is because it assumes the __experimentalSkipSerialization property. However, this property is not exposed on block.json schema. Furthermore, it is not possible to read from the schema whether the default value of shadow is true or false.

How?

I changed the type back to boolean only and defined the default value as false.

I initially simply changed the type to a boolean value as below, but this seems to cause unit tests to fail.

"shadow": {
	"type": "boolean",
	"description": "Allow blocks to define a box shadow.",
	"default": false
},

This is because the actual block.json also defines an object with the __experimentalSkipSerialization property, even though the schema expects only boolean type.

Therefore, in this PR, I limited ourselves to adding the default value (false) and description. Ideally, we might need to update the unit test logic to exclude properties with the __experimental prefix before validating the schema.

Testing Instructions

Verify that the code editor displays the correct definition using the file below.

{
	"$schema": "https://raw.githubusercontent.com/WordPress/gutenberg/block-schema/shadow-boolean/schemas/json/block.json",
	"apiVersion": 2,
	"name": "test/test",
	"title": "Test",
	"supports": {
	}
}

Screenshots or screencast

63be096f0d8789702923819396dc8493.mp4

@t-hamano t-hamano self-assigned this Feb 10, 2024
@t-hamano t-hamano added [Type] Developer Documentation Documentation for developers Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Feb 10, 2024
@t-hamano t-hamano marked this pull request as ready for review February 10, 2024 15:52
Copy link

github-actions bot commented Feb 10, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano changed the title Block JSON schema: Fix shadow definition Block JSON schema: Update shadow definition Feb 11, 2024
Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning this up @t-hamano 👍

Tested this by tweaking the button block.json file. The behaviour matches that shown in this PR's demo.

I think the reason object is allowed is because it assumes the __experimentalSkipSerialization property

Without allowing an object here, there is no means by which to opt into shadow block support but skip serialization. So both the object and boolean options are necessary.

Ideally, we might need to update the unit test logic to exclude properties with the __experimental prefix before validating the schema

This sounds like a good follow-up to me 🙂

@t-hamano
Copy link
Contributor Author

@aaronrobertshaw Thanks for the review!

@t-hamano t-hamano merged commit 3495168 into trunk Feb 12, 2024
57 checks passed
@t-hamano t-hamano deleted the block-schema/shadow-boolean branch February 12, 2024 03:36
@github-actions github-actions bot added this to the Gutenberg 17.8 milestone Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants