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

Adding default template for content type with block(having schemaEnhancer) throwing error. #5158

Closed
iFlameing opened this issue Sep 5, 2023 · 4 comments · Fixed by #5159
Closed

Comments

@iFlameing
Copy link
Member

iFlameing commented Sep 5, 2023

If you have a schema enhancer for a particular block and then you try to add this block in the layout options of content type will throw error.

Steps to reproduce the error.

  1. Create a schemaEnhancer for a particular block
  2. Go to any content type and dexterity content layout and select this block.

You will get error.

@iFlameing iFlameing changed the title Adding default template for content type with block throwing error. Adding default template for content type with block(having schemaEnhancer) throwing error. Sep 5, 2023
@davisagli
Copy link
Sponsor Member

davisagli commented Sep 5, 2023

@iFlameing Your report here is really vague.

Specifically we saw this when trying to add an image block to a layout in a project where the image block has a schema enhancer that tries to adjust the align property, which is part of the default image schema. The error is TypeError: schema.properties.align is undefined on this line in the schema enhancer: schema.properties.align.default = 'wide';

I would expect that the align property should be there, so we need to find out why it is not.

Edited to add: The problem is that schema extenders are being applied to the block layout settings schema, in addition to the main block schema.

@tiberiuichim
Copy link
Contributor

The problem is that schema extenders are being applied to the block layout settings schema, in addition to the main block schema.

CC @avoinea

@avoinea
Copy link
Sponsor Member

avoinea commented Sep 7, 2023

I would need a more details example of this in order to fully understand the issue and the relation with the DX Layout schema.

@davisagli
Copy link
Sponsor Member

@avoinea For example, we have a schema enhancer that adds "block width" and "background color" properties to a block. When editing the layout, the fields show up on both the Block and Settings tabs, because the schema enhancer is applied to both the block schema and the settings schema:

Screenshot 2023-09-07 at 7 46 08 AM Screenshot 2023-09-07 at 7 47 29 AM

Even worse, if the schema enhancer makes assumptions about the schema it is enhancing (like making a change to an existing field), then trying to use the block while editing the block layout can result in an error.

#5159 fixes this by making sure that schema enhancers are not applied to the layout settings schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants