diff --git a/__tests__/src/components/WorkspaceMosaic.test.js b/__tests__/src/components/WorkspaceMosaic.test.js index e89f5aa6f9..ed15fe9f8a 100644 --- a/__tests__/src/components/WorkspaceMosaic.test.js +++ b/__tests__/src/components/WorkspaceMosaic.test.js @@ -76,7 +76,11 @@ describe('WorkspaceMosaic', () => { }); }); it('by default use workspace.layout', () => { - wrapper = createWrapper({ windows: {}, workspace: { layout: 'foo' } }); + wrapper = createWrapper({ windows: { foo: 'bar' }, workspace: { layout: 'foo' } }); + expect(wrapper.instance().determineWorkspaceLayout()).toEqual('foo'); + }); + it('generates a new layout if windows do not match current layout', () => { + wrapper = createWrapper({ windows: { foo: 'bar' }, workspace: { layout: { first: 'foo', second: 'bark' } } }); expect(wrapper.instance().determineWorkspaceLayout()).toEqual('foo'); }); it('when window ids match workspace layout', () => { diff --git a/src/components/WorkspaceMosaic.js b/src/components/WorkspaceMosaic.js index 62381b5326..b33a6a3637 100644 --- a/src/components/WorkspaceMosaic.js +++ b/src/components/WorkspaceMosaic.js @@ -91,7 +91,11 @@ export class WorkspaceMosaic extends React.Component { layout.addWindows(addedWindows); return layout.layout; } - + // Windows were removed (perhaps in a different Workspace). We don't have a + // way to reconfigure.. so we have to random generate + if (!leaveKeys.every(e => sortedWindows.includes(e))) { + return createBalancedTreeFromLeaves(sortedWindows); + } return workspace.layout; }