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

[v14.2+] Allow custom views to load correctly for Block List #2515

Merged

Conversation

rickbutterfield
Copy link
Contributor

@rickbutterfield rickbutterfield commented Nov 6, 2024

Description

When adding a custom view for Block List items, there is sometime an instance where the custom view will not load.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Motivation and context

This appears to be happening due to a race condition between #extensionSlotFilterMethod and #renderBlock in block-list-entry.element.ts, where this._contentTypeAlias doesn't have a value before the filter method runs.

This appears to have been fixed by @nielslyngsoe in the Block Grid code based on this comment...
https://github.com/umbraco/Umbraco.CMS.Backoffice/blob/main/src/packages/block/block-grid/components/block-grid-entry/block-grid-entry.element.ts#L389

How to test?

  1. Add a new headline-umbraco-demo-block-id block to the Block List on all-property-editors-document-id in document.data.ts, around line 269
{
	editorAlias: 'Umbraco.BlockList',
	alias: 'blockList',
	culture: null,
	segment: null,
	value: {
		layout: {
			'Umbraco.BlockList': [
				{
					contentKey: '1234',
					settingsKey: '5678',
				},
+				{
+					contentKey: '2345',
+				},
			],
		},
		contentData: [
			{
				key: '1234',
				contentTypeKey: '4f68ba66-6fb2-4778-83b8-6ab4ca3a7c5c',
				elementProperty: 'Hello world',
			},
+			{
+				key: '2345',
+				contentTypeKey: 'headline-umbraco-demo-block-id',
+				headline: 'Testing 1 2 3',
+			},
		],
		...
  1. Register the block-custom-view manifest in the examples folder (I did this in entry-point.ts)
+import { manifests as testManifests } from '../../../examples/block-custom-view/index.js';
 export const onInit: UmbEntryPointOnInit = (host, extensionRegistry) => {
	...
	extensionRegistry.registerMany(coreManifests);
+	extensionRegistry.registerMany([...testManifests]);
	...
}
  1. Apply the changes as found in this PR

It does appear to work if you add a headline block to the Block List without making any of these changes, but not if loading the page with the data already in the Block List.

Screenshots (if appropriate)

Before any changes:
image
image

After adding the new Block to the List:
image

After registering the custom view:
image
image

After applying the PR changes:
image

Checklist

  • If my change requires a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@rickbutterfield rickbutterfield marked this pull request as draft November 6, 2024 14:08
@nielslyngsoe nielslyngsoe merged commit 8916717 into umbraco:main Nov 7, 2024
7 of 8 checks passed
@warrenbuckley
Copy link
Contributor

Thanks @rickbutterfield beat me to it

@warrenbuckley
Copy link
Contributor

Boo saw this was for 15.1.0 and didn't make the cut for 15.0.0 release

@rickbutterfield
Copy link
Contributor Author

I know! Was a bit gutted about that @warrenbuckley

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

Successfully merging this pull request may close these issues.

4 participants