提交 b8b3bc32 编写于 作者: J Joao Moreno

tree: collapsed resolved parent should update children visibility

上级 5bcc9db1
......@@ -507,6 +507,7 @@ export class Item {
return child.doRefresh(recursive, true);
}));
} else {
this.mapEachChild(child => child.updateVisibility());
return WinJS.TPromise.as(null);
}
});
......@@ -522,13 +523,17 @@ export class Item {
private doRefresh(recursive: boolean, safe: boolean = false): WinJS.Promise {
this.doesHaveChildren = this.context.dataSource.hasChildren(this.context.tree, this.element);
this.height = this._getHeight();
this.setVisible(this._isVisible());
this.updateVisibility();
this._onDidRefresh.fire(this);
return this.refreshChildren(recursive, safe);
}
private updateVisibility(): void {
this.setVisible(this._isVisible());
}
public refresh(recursive: boolean): WinJS.Promise {
return this.doRefresh(recursive);
}
......
......@@ -1695,4 +1695,42 @@ suite('TreeModel - bugs', () => {
assert.equal(counter.count, 0);
});
});
test('collapsed resolved parent should also update all children visibility on refresh', async function () {
const counter = new EventCounter();
const dataModel = new DynamicModel();
let isSonVisible = true;
const filter: _.IFilter = {
isVisible(_, element) {
return element !== 'son' || isSonVisible;
}
};
const model = new TreeModel({ dataSource: dataModel, filter });
dataModel.addChild('root', 'father');
dataModel.addChild('father', 'son');
await model.setInput('root');
await model.expand('father');
let nav = model.getNavigator();
assert.equal(nav.next().id, 'father');
assert.equal(nav.next().id, 'son');
assert.equal(nav.next(), null);
await model.collapse('father');
isSonVisible = false;
await model.refresh(undefined, true);
await model.expand('father');
nav = model.getNavigator();
assert.equal(nav.next().id, 'father');
assert.equal(nav.next(), null);
counter.dispose();
model.dispose();
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册