leekelleher / umbraco-contentment

Contentment for Umbraco - a state of happiness and satisfaction
https://marketplace.umbraco.com/package/umbraco.community.contentment
Mozilla Public License 2.0
157 stars 72 forks source link

Data List: Changing list-editor from Single to Multiple requires re-saving #226

Closed eden-jh closed 2 years ago

eden-jh commented 2 years ago

Which Contentment version are you using?

3.3.1

Which Umbraco version are you using? For example: 8.14.1 - don't just write v8

9.5.0

Bug summary

When changing the List editor of a data list from a single-select to a multi-select, the value of the property in the template is null until the content has been re-saved.

Steps to reproduce

  1. Create a Page document type.
  2. Add a "Fruit" property. Create a new configuration for the Contentment Data list with the following settings:
    • Data source: User-defined list (with "Apple", "Raspberry", and "Kiwi" as options, with no icons or labels selected)
    • List editor: Dropdown List
  3. Save your changes
  4. In the Page template, either add code to check/display the value of the fruit property, or add a breakpoint on the view file (anything that will allow you to see the value of Model.Fruit)
  5. Create a Page document in the Content section
  6. Select "Raspberry" in the Fruit property and save your content
  7. Go back to the settings section, and change the List editor of the data type you created in step 2 from Dropdown List to Checkbox List. Save your changes
  8. Rebuild the project so the view will use the updated models
  9. In the content section, open the page you created in step 5. Notice the item you selected in step 6 is still selected in the checkbox
  10. Go to the info tab and click the link to open the page
  11. Notice that Model.Fruit is null

I haven't tested every combination of single selection list editor to multi-select list editor, so I can't say for certain that it happens for all of them, but it definitely happens for more than one. (If I recall correctly, I think I confirmed it with radio buttons to checkboxes and dropdowns to multi-select buttons.)

Expected result / actual result

Expected result:

I'd expect the value of Model.Fruit to be a List containing the single selected option, without having to re-save the content.

Actual result:

The value of Model.Fruit is null in the template. You have to save the content again to get the correct value.

Do you have Umbraco ModelsBuilder enabled?

What browsers are you seeing the problem on?

No response

leekelleher commented 2 years ago

@eden-jh Thank you for reporting this, and for giving detailed reproduction steps - perfect! 🤩

I can reproduce the bug and working on a fix for the next release.

leekelleher commented 2 years ago

Fixed in commit 1f9462e2c625cd38691bda2756e74b8860f00ee9. It'll be part of upcoming v3.4.0 release.