Skip to content

Commit b74aadf

Browse files
leekellehernul800sebastiaan
authored andcommitted
Block editors - replaces hardcoded -20 with current node ID
1 parent ade61f7 commit b74aadf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Umbraco.Web.UI.Client/src/common/services/blockeditormodelobject.service.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
(function () {
1414
'use strict';
1515

16-
function blockEditorModelObjectFactory($interpolate, $q, udiService, contentResource, localizationService, umbRequestHelper, clipboardService, notificationsService, $compile) {
16+
function blockEditorModelObjectFactory($interpolate, $q, udiService, contentResource, localizationService, umbRequestHelper, clipboardService, notificationsService, $compile, editorState) {
1717

1818
/**
1919
* Simple mapping from property model content entry to editing model,
@@ -396,7 +396,11 @@
396396
// removing duplicates.
397397
scaffoldKeys = scaffoldKeys.filter((value, index, self) => self.indexOf(value) === index);
398398

399-
tasks.push(contentResource.getScaffoldByKeys(-20, scaffoldKeys).then(scaffolds => {
399+
// get current node (for page context)
400+
var currentPage = editorState.getCurrent();
401+
var currentPageId = currentPage ? (currentPage.id > 0 ? currentPage.id : currentPage.parentId) : null || -20;
402+
403+
tasks.push(contentResource.getScaffoldByKeys(currentPageId, scaffoldKeys).then(scaffolds => {
400404
Object.values(scaffolds).forEach(scaffold => {
401405
// self.scaffolds might not exists anymore, this happens if this instance has been destroyed before the load is complete.
402406
if (self.scaffolds) {

0 commit comments

Comments
 (0)