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

Single Block Mode forces fields to be mandatory #17309

Open
MiguelGuedelha opened this issue Oct 18, 2024 · 2 comments
Open

Single Block Mode forces fields to be mandatory #17309

MiguelGuedelha opened this issue Oct 18, 2024 · 2 comments

Comments

@MiguelGuedelha
Copy link

MiguelGuedelha commented Oct 18, 2024

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

13.5.1

Bug summary

The purpose of Single Block Mode is to help the Models Builder in giving us a single block item (for building fields which are meant to have only a single block item, and not many, such as adding a single re-usable Widget block to many pages, for example)

However, such single blocks, don't always necessarily need to exist on a page, they could be optional.

The current configuration of a block list in single mode requires the following settings:

  • Single Block Mode enabled
  • Only a given block type allowed in the list
  • Minimum 1 block
  • Maximum 1 block

When such a block list gets added to a document type as a field, it will cause the field to essentially become mandatory / you won't be able to save the page unless a block of the given list type is added to the document.

Is there a design decision somewhere that prevents the following configuration from also making ModelsBuilder generate a BlockListItem<T> with an empty list returning default(T)?

  • Single Block Mode enabled
  • Only a given block type allowed in the list
  • Minimum 0 block
  • Maximum 1 block

The mandatory/optional nature of the field would then instead be controlled by the document that uses it.

Thoughts? The current way it works essentially renders Single Block Mode useless unless the fields it is going to be used are always mandatory by nature of the document type anyways.

Specifics

No response

Steps to reproduce

  1. Have a default site installation with ModelsBuilder set to SourceCodeAuto
  2. Create a Element/block document type, can be anything
  3. Create a Block List data type that uses said Element type as its only allowed type and enable single block mode + make max amount 1 and minimum amount 1
  4. Create a document type (not an element), with a single property that uses said block list as it's editor, leave it as optional, make it so it can be created as a root component
  5. A model will be created with the property set as type BlockListItem<T>
  6. Create said document in the content tree and give it a name.
  7. Try to save the document, it won't allow to save, even though the property is optional
  8. Modify the created block list data type to have a minimum of 0 elements instead
    a. Leaving single block mode enabled or not at this point is irrelevant but try any steps after this with both
  9. Save the block list type and go back to the document in the content tree
  10. The document will not be save-able without the property being filled in
  11. The generated model will however revert back to a BlockListModel, instead of being BlockListItem<T>

Expected result / actual result

  1. Have a default site installation with ModelsBuilder set to SourceCodeAuto
  2. Create a Element/block document type, can be anything
  3. Create a Block List data type that uses said Element type as its only allowed type and enable single block mode + make max amount 1 and minimum amount 1
  4. Create a document type (not an element), with a single property that uses said block list as it's editor, leave it as optional, make it so it can be created as a root component
  5. A model will be created with the property set as type BlockListItem<T>
  6. Create said document in the content tree and give it a name.
  7. Try to save the document, it won't allow to save, even though the property is optional
  8. Modify the created block list data type to have a minimum of 0 elements instead
    a. Leave single block mode turned on
  9. Save the block list type and go back to the document in the content tree
  10. The document will now be save-able without the property being filled in
  11. The generated model remains a BlockListItem<T>, but when the value is empty in a given page/document in the CMS, the property will have default(T) as it's value when processing the ModelsBuilder generated model of the page
Copy link

Hi there @MiguelGuedelha!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

  • We'll assess whether this issue relates to something that has already been fixed in a later version of the release that it has been raised for.
  • If it's a bug, is it related to a release that we are actively supporting or is it related to a release that's in the end-of-life or security-only phase?
  • We'll replicate the issue to ensure that the problem is as described.
  • We'll decide whether the behavior is an issue or if the behavior is intended.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@NguyenThuyLan
Copy link
Contributor

Thank @MiguelGuedelha , very detail issue information.
I was able to reproduce this on v15.0.0-rc2.

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

No branches or pull requests

2 participants