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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block editors - replaces hardcoded -20 with current node ID #15063

Conversation

leekelleher
Copy link
Member

Prerequisites

  • I have added steps to test this contribution in the description below

Description

When a Block editor makes a call to contentResource.getScaffoldByKeys() (to get the element type schemas), it currently passed through a hardcoded ID of -20. This patch replaces the hardcoded ID with the current page/node's ID, with a fallback on parent page/node, (and a final fallback on the previous hardcoded ID -20.

The motivation behind this pull request is that with my Contentment package's Data List editor has a feature to make use of the current page/node, but it can only do this when the id or parentId parameters are available in the GetEmptyByKeys() content API request. This works fine within page-level property-editors, but it doesn't work with the BlockList/BlockGrid editors, (this issue also applies to NestedContent, but since that is deprecated, I didn't look to patch that too).
I regularly have support requests for Contentment to support Block editors better.

Steps to test
View a content page/node with either the BlockList or BlockGrid editors configured, and verify that it still works as expected.

In theory, this shouldn't be a breaking-change, but in reality, there may be a scenario where a developer is relying on the -20 ID being present, and would break their implementation. Personally, I can't see why someone would do this, but I submit to much wiser developers than me. 馃

@github-actions
Copy link

github-actions bot commented Oct 30, 2023

Hi there @leekelleher, thank you for this contribution! 馃憤

While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 馃挕 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 馃 馃檪

@sniffdk
Copy link
Contributor

sniffdk commented Oct 31, 2023

Thanks for this PR @leekelleher, we've (me and some colleagues) been hit by this problem just this week and are happy to see you have a fix implemented 馃檹

@nul800sebastiaan nul800sebastiaan merged commit b74aadf into umbraco:contrib Nov 29, 2023
14 of 15 checks passed
@nul800sebastiaan
Copy link
Member

Thanks for this one @leekelleher - works well and I honestly can't see it breaking anything either!

@leekelleher leekelleher deleted the patch/block-editors-scaffold-page-context branch November 29, 2023 17:12
@leekelleher
Copy link
Member Author

Super, thank you @nul800sebastiaan! 馃檹

@ljfio
Copy link

ljfio commented Jan 16, 2024

@nul800sebastiaan Is there a chance this fix could be back ported to v10? We're hitting this very problem with our build!

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.

None yet

4 participants