mirror of
https://github.com/mathuo/dockview
synced 2025-03-12 17:02:04 +00:00
fix: inserting orthogonal gridview when empty should not add new views
This commit is contained in:
parent
1462b6a37a
commit
47fb99a06f
@ -690,4 +690,37 @@ describe('gridview', () => {
|
||||
gridview.element.querySelectorAll('.mock-grid-view').length
|
||||
).toBe(4);
|
||||
});
|
||||
|
||||
test('that calling insertOrthogonalSplitviewAtRoot() for an empty view doesnt add any nodes', () => {
|
||||
const gridview = new Gridview(
|
||||
false,
|
||||
{ separatorBorder: '' },
|
||||
Orientation.HORIZONTAL
|
||||
);
|
||||
gridview.layout(1000, 1000);
|
||||
|
||||
expect(gridview.serialize()).toEqual({
|
||||
height: 1000,
|
||||
orientation: 'HORIZONTAL',
|
||||
root: {
|
||||
data: [],
|
||||
size: 1000,
|
||||
type: 'branch',
|
||||
},
|
||||
width: 1000,
|
||||
});
|
||||
|
||||
gridview.insertOrthogonalSplitviewAtRoot();
|
||||
|
||||
expect(gridview.serialize()).toEqual({
|
||||
height: 1000,
|
||||
orientation: 'VERTICAL',
|
||||
root: {
|
||||
data: [],
|
||||
size: 1000,
|
||||
type: 'branch',
|
||||
},
|
||||
width: 1000,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -455,6 +455,9 @@ export class Gridview implements IDisposable {
|
||||
this.root.size
|
||||
);
|
||||
|
||||
if (oldRoot.children.length === 0) {
|
||||
// no data so no need to add anything back in
|
||||
} else
|
||||
if (oldRoot.children.length === 1) {
|
||||
// can remove one level of redundant branching if there is only a single child
|
||||
const childReference = oldRoot.children[0];
|
||||
|
Loading…
Reference in New Issue
Block a user