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

Set block attributes to require either type or enum #45365

Merged
merged 2 commits into from
Feb 2, 2023
Merged

Set block attributes to require either type or enum #45365

merged 2 commits into from
Feb 2, 2023

Conversation

griffinjohndavid
Copy link
Contributor

What?

Updates the block.json schema to make type or enum be the required options for attributes.

Why?

The schema used for block.json currently shows an issue for block attributes that use an enum rather than type. According to the developer handbook, this works as an either or rather than just type.

How?

Changes "required": [ "type" ] into a anyOf array to require either type or enum or both

Testing Instructions

  1. Update the schema source in block.json to point to the schema file in this branch
  2. Ensure that the block attributes don't show an issue when attributes have a defined type OR enum OR both

Screenshots

Current Schema
Current Schema: error for attribute with only enum

New Schema
image_caption
Current Schema: no error for either option

@codesandbox
Copy link

codesandbox bot commented Oct 28, 2022

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @griffinjohndavid! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Oct 28, 2022
@gziolo gziolo added the [Feature] Block API API that allows to express the block paradigm. label Nov 21, 2022
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

Good catch. This is how the documentation covers it:

Screenshot 2023-02-02 at 10 41 05

As of today, we always provide type for core blocks to satisfy the schema validator. However, it doesn't need to be the case.

@gziolo gziolo merged commit a850ffc into WordPress:trunk Feb 2, 2023
@github-actions
Copy link

github-actions bot commented Feb 2, 2023

Congratulations on your first merged pull request, @griffinjohndavid! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts:

https://profiles.wordpress.org/me/profile/edit/

And if you don't have a WordPress.org account, you can create one on this page:

https://login.wordpress.org/register

Kudos!

@github-actions github-actions bot added this to the Gutenberg 15.2 milestone Feb 2, 2023
@DaisyOlsen DaisyOlsen added the [Type] Enhancement A suggestion for improvement. label Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants