Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Exception when using empty stack container #5
If you create a container of type stack with an empty content array then try and re-position a different container it will generate an error.
If there is at least one item in the stack it will work fine. I think empty stacks should work because the contents may be based on user selection which would mean they would start empty.
Originally this was by design. If a container is empty, it destroys itself. If the empty container was the only child of its parent the parent will be destroyed as well and so on. So it is virtually impossible for the user to create an empty item.
You do however make a very good point. What if I want to create a layout with some pre-defined sections, but also a specified section that I allow the user to populate dynamically – but which starts empty?
I’ll add support for this in the next release (1.0.4) which should go out in the next few days. – Watch this space for updates.
Somewhat related to this It'd be really good if when a container was marked as non-closable it would remain even if all its children are closed. So as not to break BC this could maybe be implemented as a separate container level option e.g. closeOnEmpty=true/false.
This has the same usecase as my original issue. I define an empty tab panel and allow the user to add items to it. If they add an item then remove it the parent is also removed even if set to not allow close.
v1.0.4 (released 18.10.2014) now properly supports empty stacks. In addition, configuring an item with "isClosable: false" now prevents it from being destroyed if the last of its children is destroyed. It will however still be destroyed if its parent is destroyed.
Please re-open this issue if version 1.0.4 doesn't meet your requirements. Many thanks again for pointing it out.