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

Unable to add child items #856

Closed
danwellman opened this issue Sep 20, 2023 · 1 comment
Closed

Unable to add child items #856

danwellman opened this issue Sep 20, 2023 · 1 comment

Comments

@danwellman
Copy link

I am trying to add a new item to an existing layout (the layout is working).

In golden-layout 1.5.9 I was able to create config for a new item like this:

const newItemConfig = {
  title: 'New Item',
  type: 'component',
  componentName: 'my-registered-type',
},

Then I was able to add this to the layout like this:

myLayout.root.contentItems[0].addChild(newItemConfig);

In golden-layout 2.6.0 I've updated the config to this:

const testConfig = {
  title: 'New Item',
  type: ItemType.component,
  componentType: 'widget-golden-instance',
}

and I'm trying to add it like this:

myLayout.rootItem.contentItems[0].addChild(newItemConfig);

This is giving me an error that the argument is not of the type ContentItem. It isn;t possible to create instances of ContentItem manually as it's an abstract class, so instead I tried to use the layout's createAndInitContentItem method to create the content item, passing it the newItemConfig, like this:

const newContentItem = myLayout.createAndInitContentItem(newItemConfig, gl.rootItem.contentItems[0])

But this method will not accept the newItemConfig - it complains that "string is not assignable to ItemType" even though I am using the ItemType enum imported from the library.

There appears to be no way out of this conundrum, and the migration guide for gl2 makes no mention of adding new items to a layout dynamically.

@yansenlei
Copy link

I have the same problem

Any News?

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