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

Content Blocks - Editor is not rendered when the value contains a non-existent block type #346

Closed SteveVaneeckhout closed 1 year ago

SteveVaneeckhout commented 1 year ago

Which Contentment version are you using?

4.4.6

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

12.2

Bug summary

When I remove a Block Type from a Contentment.ContentBlocks datatype, the editor will not be shown when the value contains the removed Block Type.

The browser console shows the following error in Edge:

Cannot read properties of undefined (reading 'previewEnabled')
    at w (contentment.js?d=638318364500000000:1:15097)

or Firefox:

TypeError: v.elementTypeLookup[r.elementType] is undefined
    w contentment.js:1

This points to: https://github.com/leekelleher/umbraco-contentment/blob/dd401c4b8c95ae4d0942f155849c775962aa60c3/src/Umbraco.Community.Contentment/DataEditors/ContentBlocks/content-blocks.js#L264

Steps to reproduce

Expected result / actual result

The Contentment editor should be shown without errors and only show rules that are available.

Do you have Umbraco ModelsBuilder enabled?

What browsers are you seeing the problem on?

Firefox, Microsoft Edge

leekelleher commented 1 year ago

Following on from my feedback on https://github.com/leekelleher/umbraco-contentment/pull/347#pullrequestreview-1655166140, I've explored an alternative approach for the UI. To fade out the unsupported block item, keeping the value in place, so that a content-editor can manually remove it or copy the raw JSON value.

Content Blocks editor with a disabled block

The changes are in commit 7fbbb04bdd92383f2b5414e50b509fd295f7d1b3. It'd be part of the upcoming Contentment v4.5.0 release.