Skip to content

Commit

Permalink
Handle edge case where windows are removed from a different workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
mejackreed committed Apr 5, 2019
1 parent 9eb19da commit 59846d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion __tests__/src/components/WorkspaceMosaic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
6 changes: 5 additions & 1 deletion src/components/WorkspaceMosaic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 59846d4

Please sign in to comment.