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

Cannot get variantId of property #16859

Closed
jojo308 opened this issue Aug 3, 2024 · 2 comments · Fixed by umbraco/Umbraco.CMS.Backoffice#2214
Closed

Cannot get variantId of property #16859

jojo308 opened this issue Aug 3, 2024 · 2 comments · Fixed by umbraco/Umbraco.CMS.Backoffice#2214

Comments

@jojo308
Copy link

jojo308 commented Aug 3, 2024

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

14.1.1

Bug summary

I have a property editor where I want to retrieve the unique and variantId of the node that is being edited. However, I am unable to retrieve the variantId/culture. In older versions of Umbraco I could use editorState.variants.find(x => x.active), but this doesn't exist anymore and I can't find any alternatives.
I've tried using some available contexts like UMB_WORKSPACE_CONTEXT and UMB_PROPERTY_CONTEXT but when I try to access the variant it returns undefined.

The following code snippet should return the variantId but it returns undefined instead.

this.consumeContext(UMB_PROPERTY_CONTEXT, (ctx) => {
    this._propertyContext = ctx;

    this.observe(this._propertyContext.variantId, (id) => {
        console.log('UMB_PROPERTY_CONTEXT:variantId:', id)
        if (id && id.culture !== undefined) {           
            console.log(':UMB_PROPERTY_CONTEXT:culture:', id.culture)
        } else {
            console.log('UMB_PROPERTY_CONTEXT:culture is undefined')
        }
    })
})

override async connectedCallback() {
    super.connectedCallback();
    console.log('UMB_PROPERTY_CONTEXT:variantId:', this._propertyContext?.getVariantId())
}

My property editor is located in a block list item if that helps. When the property editor is located in a document directly instead of a block list item, I can actually get the variantId.

Data when the property editor is in a document:
image
Data when the property editor is in a block list:
image

Specifics

No response

Steps to reproduce

I've made a repo with my property editor: https://github.com/jojo308/Umbraco.Variant.Issue

  1. Clone the repo
  2. Run the site and go to the backoffice (credentials are in the README)
  3. Go to the home node and open the block item of the Standard Header property.
  4. Check the console in Developer Tools.

Expected result / actual result

I expect the variant to have a value instead of undefined.

Copy link

github-actions bot commented Aug 3, 2024

Hi there @jojo308!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

  • We'll assess whether this issue relates to something that has already been fixed in a later version of the release that it has been raised for.
  • If it's a bug, is it related to a release that we are actively supporting or is it related to a release that's in the end-of-life or security-only phase?
  • We'll replicate the issue to ensure that the problem is as described.
  • We'll decide whether the behavior is an issue or if the behavior is intended.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@nielslyngsoe
Copy link
Member

Hi @jojo308 Very good case, thanks for reporting this. 🤩

I have made a fix for this, as we surely did miss the VariantID binding to Block Workspace.
Here: umbraco/Umbraco.CMS.Backoffice#2214

I see that you got a pretty good understanding of the system, so please share your learning process with me, and let me know how it works for you. Both from a technical and from a learning experience perspective.

Then we can use that to improve code or improve Documentation.

Feel free to get in contact with me on one of these platforms:

Discord: nielslyngsoe
LinkedIn: https://www.linkedin.com/in/nielslyngsoe/

Thanks in advance

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

Successfully merging a pull request may close this issue.

4 participants