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

Blocks: Update schema to require either a type or an enum #36267

Merged
merged 1 commit into from
Nov 5, 2021

Conversation

walbo
Copy link
Member

@walbo walbo commented Nov 5, 2021

Description

Part of #35902.

The attribute definition will contain, at a minimum, either a type or an enum. There may be additional fields.

Update the block.json schema to require either a type or an enum prop.

How has this been tested?

Screenshots

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

Part of #35902.

Update the block.json schema to require either a `type` or an `enum` prop.
Copy link
Member

@fabiankaegy fabiankaegy left a comment

Choose a reason for hiding this comment

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

Didn't know this was possible :) Thanks for the fix (y)

@fabiankaegy fabiankaegy merged commit 63630f3 into trunk Nov 5, 2021
@fabiankaegy fabiankaegy deleted the update/blocks-attributes-required-enum-or-type branch November 5, 2021 19:25
@github-actions github-actions bot added this to the Gutenberg 12.0 milestone Nov 5, 2021
@gziolo
Copy link
Member

gziolo commented Nov 8, 2021

Thank you for the fix 👍🏻

#36264 updates the template lock attribute to use both the type and enum.

In practice, both type and enum are completely optional. I assume it has to stay this way for backward compatibility. However, for the schema, we could be more strict. The current proposal is quite reasonable unless we want to always enforce the type which wouldn't be a bad idea. I have just noticed that the type should also allow an array of types.

@gziolo gziolo added [Feature] Block API API that allows to express the block paradigm. [Type] Enhancement A suggestion for improvement. labels Nov 8, 2021
@walbo
Copy link
Member Author

walbo commented Nov 8, 2021

Yes. After I created this PR I discovered an issue with only having enum on SSR blocks (see #36319), so enforcing type would be great.

@ajlende ajlende added the Backport to WP Minor Release Pull request that needs to be backported to a WordPress minor release label Jan 28, 2022
@ajlende ajlende removed the Backport to WP Minor Release Pull request that needs to be backported to a WordPress minor release label Jan 28, 2022
@bph bph added the Needs Dev Note Requires a developer note for a major WordPress release cycle label Mar 24, 2022
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. Needs Dev Note Requires a developer note for a major WordPress release cycle [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants