Skip to content

Commit

Permalink
Fix dash container model allow remove (#3490)
Browse files Browse the repository at this point in the history
* Fix bug where `DashContainerModel.addView` would throw when adding a view to a row or column

* Fix bug where `DashContainerModel` would drop `allowRemove` from state for containers
  • Loading branch information
ghsolomon authored Oct 6, 2023
1 parent c2bcc95 commit 6fb4b75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

### 🐞 Bug Fixes

* Fix bug where `DashContainerModel.addView` would throw when adding a view to a row or column
* `DashContainerModel` fixes:
* Fix bug where `addView` would throw when adding a view to a row or column
* Fix bug where `allowRemove` flag was dropped from state for containers

## 59.1.0 - 2023-09-20

Expand Down
8 changes: 4 additions & 4 deletions desktop/cmp/dash/container/impl/DashContainerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ function convertGLToStateInner(configItems = [], contentItems = [], dashContaine

ret.push(view);
} else {
const {type, width, height, activeItemIndex, content} = configItem,
container = {type} as PlainObject;
const {type, width, height, activeItemIndex, content, isClosable} = configItem,
container = {type, allowRemove: isClosable} as PlainObject;

if (isFinite(width)) container.width = round(width, 2);
if (isFinite(height)) container.height = round(height, 2);
Expand Down Expand Up @@ -138,12 +138,12 @@ function convertStateToGLInner(items = [], viewSpecs = [], containerSize, contai
const content = convertStateToGLInner(item.content, viewSpecs, itemSize, item).filter(
it => !isNil(it)
);
if (!content.length) return null;
if (!content.length && item.allowRemove) return null;

// Below is a workaround for issue https://github.com/golden-layout/golden-layout/issues/418
// GoldenLayouts can sometimes export its state with an out-of-bounds `activeItemIndex`.
// If we encounter this, we overwrite `activeItemIndex` to point to the last item.
const ret = {...item, content};
const ret = {...item, content, isClosable: item.allowRemove};
if (
type === 'stack' &&
isFinite(ret.activeItemIndex) &&
Expand Down

0 comments on commit 6fb4b75

Please sign in to comment.