Skip to content

Commit

Permalink
Merge branch 'develop' into PlaywrightTesting
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryanseanlee committed Oct 9, 2023
2 parents 1c2a70d + 6fb4b75 commit 9749d50
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## 60.0.0-SNAPSHOT - unreleased

### 🐞 Bug Fixes

* `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

### 🎁 New Features
Expand Down
5 changes: 3 additions & 2 deletions desktop/cmp/dash/container/DashContainerModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {wait} from '@xh/hoist/promise';
import {isOmitted} from '@xh/hoist/utils/impl';
import {debounced, ensureUniqueBy, throwIf} from '@xh/hoist/utils/js';
import {createObservableRef} from '@xh/hoist/utils/react';
import {cloneDeep, defaultsDeep, find, isFinite, isNil, reject, startCase} from 'lodash';
import {cloneDeep, defaultsDeep, find, isFinite, isNil, last, reject, startCase} from 'lodash';
import {createRoot} from 'react-dom/client';
import {DashConfig, DashModel} from '../';
import {DashViewModel, DashViewState} from '../DashViewModel';
Expand Down Expand Up @@ -290,7 +290,8 @@ export class DashContainerModel extends DashModel<

if (!isFinite(index)) index = container.contentItems.length;
container.addChild(goldenLayoutConfig(viewSpec), index);
wait(1).then(() => this.onStackActiveItemChange(container));
const stack = container.isStack ? container : last(container.contentItems);
wait(1).then(() => this.onStackActiveItemChange(stack));
}

/**
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 9749d50

Please sign in to comment.