Skip to content

Commit 019563b

Browse files
andrejd22Andrej DavidovičiOvergaard
authored
Fix: custom block view rendering (#19962)
* Fix: custom block view rendering * chore: formatting * chore: formatting * chore: marks render method as class property to bind it properly to the class so it can run private methods and does not lose its context see also #extensionSlotRenderMethod --------- Co-authored-by: Andrej Davidovič <[email protected]> Co-authored-by: Jacob Overgaard <[email protected]>
1 parent e82da17 commit 019563b

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-entry/block-grid-entry.element.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -467,12 +467,11 @@ export class UmbBlockGridEntryElement extends UmbLitElement implements UmbProper
467467
<umb-extension-slot
468468
.filter=${this.#extensionSlotFilterMethod}
469469
.renderMethod=${this.#extensionSlotRenderMethod}
470+
.defaultRenderMethod=${this.#renderBuiltinBlockView}
470471
.props=${this._blockViewProps}
471472
default-element=${this._inlineEditingMode ? 'umb-block-grid-block-inline' : 'umb-block-grid-block'}
472473
type="blockEditorCustomView"
473-
single
474-
>${this.#renderBuiltinBlockView()}</umb-extension-slot
475-
>
474+
single></umb-extension-slot>
476475
${this.#renderActionBar()}
477476
${!this._showContentEdit && this._contentInvalid
478477
? html`<uui-badge attention color="invalid" label="Invalid content">!</uui-badge>`
@@ -494,15 +493,15 @@ export class UmbBlockGridEntryElement extends UmbLitElement implements UmbProper
494493
: nothing;
495494
}
496495

497-
#renderBuiltinBlockView() {
496+
#renderBuiltinBlockView = () => {
498497
if (this._unsupported) {
499498
return this.#renderUnsupportedBlock();
500499
}
501500
if (this._inlineEditingMode) {
502501
return this.renderInlineBlock();
503502
}
504503
return this.#renderRefBlock();
505-
}
504+
};
506505

507506
#renderUnsupportedBlock() {
508507
return html`<umb-block-grid-block-unsupported

src/Umbraco.Web.UI.Client/src/packages/core/extension-registry/components/extension-slot/extension-slot.element.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ export class UmbExtensionSlotElement extends UmbLitElement {
9797
index: number,
9898
) => TemplateResult | TemplateResult<1> | HTMLElement | null | undefined | typeof nothing;
9999

100+
@property({ attribute: false })
101+
public defaultRenderMethod?: () =>
102+
| TemplateResult
103+
| TemplateResult<1>
104+
| HTMLElement
105+
| null
106+
| undefined
107+
| typeof nothing;
108+
100109
override connectedCallback(): void {
101110
super.connectedCallback();
102111
this.#attached = true;
@@ -136,7 +145,9 @@ export class UmbExtensionSlotElement extends UmbLitElement {
136145
return this._permitted
137146
? this._permitted.length > 0
138147
? repeat(this._permitted, (ext) => ext.alias, this.#renderExtension)
139-
: html`<slot></slot>`
148+
: this.defaultRenderMethod
149+
? this.defaultRenderMethod()
150+
: html`<slot></slot>`
140151
: nothing;
141152
}
142153

0 commit comments

Comments
 (0)