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

Params in component not accessible #24

Open
ienemien opened this issue Sep 19, 2023 · 2 comments
Open

Params in component not accessible #24

ienemien opened this issue Sep 19, 2023 · 2 comments
Assignees

Comments

@ienemien
Copy link

We are trying to add some 'dynamic' parameters (not dynamic as in that they are added to the component config of a dynamic component, but I extended the backend so that these parameters are added dynamically). This means they are not in the "paramsInfo" in the pagemodel, but in the "params" (this is expected according to this documentation: https://xmdocumentation.bloomreach.com/library/concepts/page-model-api/page-model-api-v1.0.html).

I also see this field in the ContainerItemMeta interface in: https://github.com/bloomreach/spa-sdk/blob/main/packages/spa-sdk/src/page/container-item.ts but they are not returned when calling component.getParameters() and there's also no other method to reach them. Would it be possible to return them in addition to the paramsInfo when calling getParameters()? I see that in the Component class, it does return the params instead of paramsInfo, but most of the components where we want this are of type ContainerItemImpl.

@joerideg
Copy link
Contributor

Hi @ienemien ,
Sorry for the late reply, it slipped my radar.
Yes I agree this should be possible and is not right now. I notice that in the Component class the getProperties method returns the meta.params but then we override it in the ContainerItem class by returning meta.paramsInfo. We should at least return a merge of the two.

I'll plan in an improvement issue for this.

@joerideg
Copy link
Contributor

joerideg commented Oct 18, 2023

As a temporary work around you can access the params and paramsInfo properties directly from the component instance models.meta property like:

const params = props.component.model.meta.params; 
const paramsInfo = props.component.model.meta.paramsInfo; 

Of course you might have to convince Typescript that this is ok :)

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

No branches or pull requests

2 participants